Skip to content

Instantly share code, notes, and snippets.

@MorenoMdz
Created May 29, 2021 02:14
Show Gist options
  • Save MorenoMdz/09c47fe45ed6cff38abc87e76d7168ff to your computer and use it in GitHub Desktop.
Save MorenoMdz/09c47fe45ed6cff38abc87e76d7168ff to your computer and use it in GitHub Desktop.
Small method to listen for Enter key press
const Input = () => {
const handleKeyDown = (event) => {
if (event.key === 'Enter') {
console.log('do validate')
}
}
return <input type="text" onKeyDown={handleKeyDown} />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment