title: Simulate KeyPress Enter for Google Chrome in pure javascript
body: <p>I'm trying to simulate Enter Key. Nothing seems to happen with my attempt to do so :</p>
  
  <p><a href="https://jsfiddle.net/jn4zy1fc/4/" rel="nofollow">https://jsfiddle.net/jn4zy1fc/4/</a></p>
  
  <pre><code>  &lt;form&gt;
      &lt;input type="text" id="field" onkeydown="test(event);"&gt;
    &lt;/form&gt;
  
    &lt;script&gt;
       function test(ev){
          if(ev.keyCode == 13){
          alert ("enter key");
          }
       }
  
          field = document.getElementById("field");
          var e = document.createEvent("KeyboardEvent"); 
          e.initKeyboardEvent("keydown", true, true, window,true, false, false, false,13, 0);
          field.dispatchEvent(e);     
    &lt;/script&gt;
  </code></pre>