From 2ec1a724853cc11ce6393238dfc2c41df75da3af Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Mon, 23 Feb 2026 11:08:27 +0300 Subject: [PATCH] fix: close editor on Escape key press --- .../code-editor/hooks/useEditorKeyboardShortcuts.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/code-editor/hooks/useEditorKeyboardShortcuts.ts b/src/components/code-editor/hooks/useEditorKeyboardShortcuts.ts index 1cc99f2..d98e54d 100644 --- a/src/components/code-editor/hooks/useEditorKeyboardShortcuts.ts +++ b/src/components/code-editor/hooks/useEditorKeyboardShortcuts.ts @@ -13,16 +13,19 @@ export const useEditorKeyboardShortcuts = ({ }: UseEditorKeyboardShortcutsParams) => { useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + event.preventDefault(); + onClose(); + return; + } + if (!(event.ctrlKey || event.metaKey)) { return; } - if (event.key === 's') { + if (event.key.toLowerCase() === 's') { event.preventDefault(); onSave(); - } else if (event.key === 'Escape') { - event.preventDefault(); - onClose(); } };