title: How can I simulate keys entered in an input web element in Chrome 56 with pure JavaScript?
body: <p>I am developing some programmatic automation within a web page and am attempting to enter a keystroke into an input web element in Chrome 56 (specifically 56.0.2924.87) and cannot seem to get it working.</p>
  
  <p>I have done my homework and attempted MANY online examples including the ones found here: <a href="https://stackoverflow.com/questions/40064517/javascript-simulate-key-events-on-chrome-53">Javascript - simulate key events on Chrome 53</a>, but with no luck.  </p>
  
  <p>This is my most recent (currently non-working) attempt based on the solution provided in the question above:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;Keyboard Events&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;input id="id_input" onkeydown="console.log(event);"&gt;
    &lt;button onclick="
      var e = new Event('keydown');
      e.keyCode = 65;
      document.getElementById('id_input').dispatchEvent(e);
      "&gt;click me&lt;/button&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>You can observe the event being generated, but no character appears in the input web element.</p>
  
  <p>I would <strong>greatly</strong> appreciate a working JavaScript only example, working in Chrome 56, of pressing a button on a page and a character appearing in the input web element WITHOUT setting the "value" property of the input web element.  The working solution must be causing characters to appear only by using events (presumably keypress/keydown, etc.)</p>
  
  <p>UPDATE: My issue is different than this issue: <a href="https://stackoverflow.com/questions/2490825/how-to-trigger-event-in-javascript">How to trigger event in JavaScript?</a> because I'm already using the dispatchEvent method listed in the solution. The answer to my question will likely include an additional step not already outlined in the multiple attempts from the first link I included.</p>