title: fireEvent.keyDown not working as expected on my Jest + React Testing Library test
body: <p>In my current React project, I'm testing a component which includes, as child component, the <a href="https://material-ui.com/components/dialogs/" rel="noreferrer">Dialog component from Material UI</a>.</p>
  
  <p>It's supposed it has to run the <code>onClose()</code> function when the user presses the <code>Esc</code> key. I tested it manually and it works perfectly well. Now I'm doing the same test, this time using <strong>Jest + React Testing Library</strong>. You can see the code below:</p>
  
  <pre><code>fireEvent.keyDown(container, {
        key: "Escape",
        code: "Escape",
        keyCode: 27,
        charCode: 27
      });
  </code></pre>
  
  <p>And the test doesn't pass. After some debugs, I've realized that the event is actually being triggered, but for some reason is not having an impact on the <code>&lt;Dialog/&gt;</code> component.</p>
  
  <p>So I did run the component on Google Chrome, and triggered the same event from the Dev Tools console with the following code: </p>
  
  <pre><code>document.dispatchEvent(
      new KeyboardEvent(
          "keydown", {     
              key: "Escape",
              code: "Escape",
              keyCode: 27,
              charCode: 27
          }
      )
  );
  </code></pre>
  
  <p>...and it doesn't work either.</p>
  
  <p>What can I do to make this test pass?</p>