on enter key press react

JavaScript
onKeyPress={(e) => e.key === 'Enter' && handleSearch()}var Input = React.createClass({
  render: function () {
    return <input type="text" onKeyDown={this._handleKeyDown} />;
  },
  _handleKeyDown: function(e) {
    if (e.key === 'Enter') {
      console.log('do validate');
    }
  }
});
const Enter = () => {
  	const handle = () => console.log('Enter pressed');
  
	return <input type="text" onKeyDown={e => e.key === 'Enter' && handle} />;
};
Source

Also in JavaScript: