feat: close notepad on escape

This commit is contained in:
MAZE 2024-04-27 19:53:59 +03:30
parent 60f167c4d7
commit 583578b315

View file

@ -39,6 +39,12 @@ export function Notepad({ onClose, show }: NotepadProps) {
}
}, [show]);
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
e.stopPropagation();
if (e.key === 'Escape') onClose();
};
return (
<Modal show={show} wide onClose={onClose}>
<header className={styles.header}>
@ -71,7 +77,7 @@ export function Notepad({ onClose, show }: NotepadProps) {
ref={textareaRef}
value={note}
onChange={e => write(e.target.value)}
onKeyDown={e => e.stopPropagation()}
onKeyDown={handleKeyDown}
/>
<p className={styles.counter}>