mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 17:04:15 +00:00
refactor: better shortcut handling
This commit is contained in:
parent
98e5021f56
commit
f81ea9e7bd
1 changed files with 3 additions and 3 deletions
|
|
@ -39,8 +39,8 @@ export function Modal({
|
||||||
}, [show, lockBody]);
|
}, [show, lockBody]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function keyListener(e) {
|
function keyListener(e: KeyboardEvent) {
|
||||||
if (e.keyCode === 27) {
|
if (e.key === 'escape') {
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ export function Modal({
|
||||||
document.addEventListener('keydown', keyListener);
|
document.addEventListener('keydown', keyListener);
|
||||||
|
|
||||||
return () => document.removeEventListener('keydown', keyListener);
|
return () => document.removeEventListener('keydown', keyListener);
|
||||||
});
|
}, [onClose]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Portal>
|
<Portal>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue