react on enter window code example
Example 1: on enter key press react
onKeyPress={(e) => e.key === 'Enter' && handleSearch()}
Example 2: react detect enter key
var Input = React.createClass({
render: function () {
return <input type="text" onKeyDown={this._handleKeyDown} />;
},
_handleKeyDown: function(e) {
if (e.key === 'Enter') {
console.log('do validate');
}
}
});