title: How to detect 'Enter' key on keyPress when used with React
body: <p>I am using ReactJs to develop my application. I am trying to submit an input text when Enter is pressed by handling the onKeyPress event. It detects other inputs, but not enter. I have tried different ways - <code>event.key</code>, <code>event.charCode</code>, <code>event.keyCode</code>, <code>event.which</code>... Nothing seems to work.</p>
  
  <pre><code>React.createElement("input", {tabIndex: "1", onKeyPress: this.handleKeyPress, onChange: this.handleChange, 
                             placeholder: "ex: 1,10,15"}), 
  
  handleChange: function (event) {
          this.setState({userInputBuckets: event.target.value});
      },
  handleKeyPress: function (event) {
          if (event.charCode == 13) {
              event.preventDefault();
              this.props.table.handleSubtotalBy(this.props.columnDef, this.state.userInputBuckets);
          }
      },
  </code></pre>
  
  <p>I also tried with <code>onKewDown</code> handling, it detects the correct key, but it doesn't execute the if block even though it evaluates <code>event.keyCode == 13</code> as true.</p>