mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
refactor: better shortcut handling
This commit is contained in:
parent
98e5021f56
commit
f81ea9e7bd
@ -39,8 +39,8 @@ export function Modal({
|
||||
}, [show, lockBody]);
|
||||
|
||||
useEffect(() => {
|
||||
function keyListener(e) {
|
||||
if (e.keyCode === 27) {
|
||||
function keyListener(e: KeyboardEvent) {
|
||||
if (e.key === 'escape') {
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ export function Modal({
|
||||
document.addEventListener('keydown', keyListener);
|
||||
|
||||
return () => document.removeEventListener('keydown', keyListener);
|
||||
});
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<Portal>
|
||||
|
Loading…
x
Reference in New Issue
Block a user