title: Create KeyEvent in Javascript
body: <p>I have the following problem - I'm catching a key event an I need to create a new altered key event(since it seems the keyCode property is read-only) and afterwards handle the newly created KeyEvent. I came across several old posts in StackOverflow where similar situations are handled, but:</p>
  
  <ul>
  <li><p>I need this to be working under Webkit /there's a solution here in StackOverfow but it is working only in Gecko/</p></li>
  <li><p>I need to create another KeyEvent, but not TextInputEvent, since the TextInputEvent will only let my specify a string to be inserted, whilst I cannot do that as I use a third party tool that needs to handle this event and I need a keycode.</p></li>
  <li><p>I tried <code>jQuery#trigger()</code> but it won't work for me. My code is as follows</p>
  
  <pre><code>var event = jQuery.event('keydown');
  event.which = 13; //I'm trying to simulate an enter
  $('iframe').contents().find('document').find('body').trigger(event); //my content is inside an iframe
  </code></pre></li>
  </ul>