Why does my jQuery triggered keyup event get lost?
<p>I'm using jQuery 1.7.1</p>

<p>My <code>keyup</code> handler works fine, even though the setup is a little complicated.  This is happening in an iframe overlay.  The main page does
</p>

<pre class="lang-js prettyprint-override"><code>our.Catalog.makeViewer = function(id) {
  var iframe = document.createElement('iframe');
  iframe.setAttribute()... // src, id, name, etc.  Exact same host and method
  document.body.appendChild(iframe);
  iframe.contentWindow.focus();
  $('html, body').css('overflow', 'hidden');
}
our.Catalog.makeViewer('foo') // actually bound to a click hander
</code></pre>

<p>In the iframe <code>&lt;head&gt;</code> we have something like</p>

<pre class="lang-js prettyprint-override"><code>our.Viewer = function(){
   $(document).keyup(function(e){ doSomething() })
   // and lots more, of course
}
$(function() {
  new our.Viewer();
});
</code></pre>

<p>The browser displays the URL of the iframe.  I get all the real keyups for the whole browser window which is fine, but for testing I want to be able to simulate keyups from JavaScript.  However, whatever I try doesn't work. I've tried</p>

<pre class="lang-js prettyprint-override"><code>$('body').trigger($.Event('keyup', {keycode: 40}))
$(document).trigger($.Event('keyup', {keycode: 40})) 
$(document).keyup()
</code></pre>

<p>and none of them triggered my handler.  Then I thought maybe the problem was that I'm using iframes, so I tried</p>

<pre class="lang-js prettyprint-override"><code>$('#frameId').contents().find('body').trigger($.Event('keyup', {keycode: 40}))
</code></pre>

<p>Nope, that doesn't work either.  I don't think it's any kind of permissions/security issue because <code>$('#frameId').contents().find('body').addClass('test')</code> works fine. </p>

<p>I hope I'm doing something stupid someone can easily correct.  How can I simulate keyups from my JavaScript driver? </p>
