I am using Material UI for my React project and unable to detect when the enter key has been pressed. I have tried the following which I thought should work but still unable to detect the event, not sure what I am missing.
I have a custom MUI component
const [search, setSearch] = useState('');
const handleChange = (event) => {
setSearch(event.target.value);
if (event.keyCode == 13) {
console.log('enter key was pressed');
}
}
<SearchBox
value={search}
onChange={handleChange}
placeholder="enter your search here"
}}
/>