How to trigger a button click on Enter in React code example Example: on enter key press react onKeyPress={(e) => e.key === 'Enter' && handleSearch()}