-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to close modal with ESC key #10
Labels
enhancement
New feature or request
Comments
Maybe something like this would work? const keyboardShortcuts = useCallback((event) => {
if (event.keyCode === 27) {
closeModal();
}
}, []);
useEffect(() => {
document.addEventListener('keydown', keyboardShortcuts);
return () => document.removeEventListener('keydown', keyboardShortcuts);
}); |
@EdmundoJr Thanks for the suggestion! I've not tried it but it looks reasonable. Feel free to PR a change, otherwise I will try to get round to implementing this in the near future. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would be a useful addition to help move around the UI with just the keyboard.
The text was updated successfully, but these errors were encountered: