capture enter button react input code example
Example 1: capture enter button react input
const Enter = () => {
const handle = () => console.log('Enter pressed');
return e.key === 'Enter' && handle} />;
};
Example 2: react detect enter key
var Input = React.createClass({
render: function () {
return ;
},
_handleKeyDown: function(e) {
if (e.key === 'Enter') {
console.log('do validate');
}
}
});