diff --git a/src/components/editor/editor.tsx b/src/components/editor/editor.tsx index 39ace8f6e..36fcab04d 100644 --- a/src/components/editor/editor.tsx +++ b/src/components/editor/editor.tsx @@ -66,9 +66,9 @@ export const Editor: React.FC = () => { }, [updateDocumentTitle]) useEffect(() => { - document.addEventListener('keyup', shortcutHandler, false) + document.addEventListener('keydown', shortcutHandler, false) return () => { - document.removeEventListener('keyup', shortcutHandler, false) + document.removeEventListener('keydown', shortcutHandler, false) } }, []) diff --git a/src/components/editor/shortcut/shortcut.ts b/src/components/editor/shortcut/shortcut.ts index b14c1b3b8..853212d5f 100644 --- a/src/components/editor/shortcut/shortcut.ts +++ b/src/components/editor/shortcut/shortcut.ts @@ -4,13 +4,16 @@ import { EditorMode } from '../app-bar/editor-view-mode' export const shortcutHandler = (event: KeyboardEvent): void => { if (event.ctrlKey && event.altKey && event.key === 'b') { setEditorMode(EditorMode.BOTH) + event.preventDefault() } if (event.ctrlKey && event.altKey && event.key === 'v') { setEditorMode(EditorMode.PREVIEW) + event.preventDefault() } - if (event.ctrlKey && event.altKey && event.key === 'e') { + if (event.ctrlKey && event.altKey && (event.key === 'e' || event.key === '€')) { setEditorMode(EditorMode.EDITOR) + event.preventDefault() } }