react on enter key press and onchange code example
Example 1: on enter key press react
onKeyPress={(e) => e.key === 'Enter' && handleSearch()}
Example 2: capture enter button react input
const Enter = () => {
const handle = () => console.log('Enter pressed');
return <input type="text" onKeyDown={e => e.key === 'Enter' && handle} />;
};