title: How to trigger keypress event in React.js
body: <p>I'm new to React.js.
  I'm trying to trigger keypress event for text div.</p>
  
  <p>Here is text box code for which I want to execute keypress trigger.</p>
  
  <pre><code>&lt;div id="test23" contenteditable="true" class="input" placeholder="type a message" data-reactid="137"&gt;Hii...&lt;/div&gt;
  </code></pre>
  
  <p>and keypress method is:</p>
  
  <pre><code>onKeyPress: function(e) {
     return "Enter" == e.key ? "Enter key event triggered" : void 0)
  }
  </code></pre>
  
  <p>I tried it with jQuery but I can't trigger it.</p>
  
  <p>Here is my React code that I tried but its not working:</p>
  
  <pre><code>var event = new Event('keypress', {
   'keyCode' : 13,
   'which' : 13,
   'key' : 'Enter'
  });
  var node = document.getElementById('test23');
  node.dispatchEvent(event);
  </code></pre>