title: Sending keyboard events programmatically doesn't dispatch them into inputs
body: <p>I am sending programmatically generated keyboard events to the document. I was hoping that the currently focused input element would display them, however it doesn't. The events are generated from a string with this function:</p>
  
  <pre><code>const simulateKeyPress = keys =&gt; {
    keys.split('').forEach(theKey =&gt; {
      const e = new window.KeyboardEvent('keypress', {
        bubbles: true,
        key: theKey,
        keyCode: theKey.charCodeAt(0),
        charCode: theKey.charCodeAt(0),
      })
      document.dispatchEvent(e)
    })
  }
  </code></pre>
  
  <p>If I add an EventListener to the document it'll receive all the events. Their <code>isTrusted</code> flag is set to false however, might this be the issue?</p>