Created
June 16, 2020 02:42
-
-
Save karenying/67192e644c76dcb4621a37e737f005b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const handleKeyDown = (e) => { | |
if (e.keyCode === 39) { | |
onArrowClick('right'); | |
} | |
if (e.keyCode === 37) { | |
onArrowClick('left'); | |
} | |
}; | |
window.addEventListener('keydown', handleKeyDown); | |
return () => { | |
window.removeEventListener('keydown', handleKeyDown); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment