title: chrome extension: how to send 'keydown' event to page's input?
body: <p>I have a test web page that alerts if i hit a key in it's input field:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;script type="text/javascript" src="jquery-1.9.1.min.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      $( document ).ready( function() {
        $( '#foo' ).keydown( function() { alert( "debug" ); } );
      });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;input id='foo' type='type'/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And i have this chrome extension that modifies input text and fires keydown event:</p>
  
  <pre><code>$( document ).ready( function() {
    window.setTimeout( function() {
      $( '#foo' ).val( "foo" );
      $( '#foo' ).keydown();
    }, 2000 );
  });
  </code></pre>
  
  <p>If i install extension, after 2 seconds (as expected) text is modified - but alert is not displayed, so i can suggest that <code>keydown</code> event is not passed from extension sandbox into page javascript handler. Is it possible to modify my code somehow so extension can emulate keydown that javascript on the page can see? I'm automating a third-party website via chrome extension, and one of the inputs requires <code>keyup</code> to detect value change (the page i'm automating is written badly - but i don't have any control other it's source code).</p>