(e: KeyboardEvent, editor: EditorWrapper, dialogStore: DialogStore)
| 78 | } |
| 79 | |
| 80 | export async function onKeyDown(e: KeyboardEvent, editor: EditorWrapper, dialogStore: DialogStore) { |
| 81 | const key = await getLocalizedScanCode(e); |
| 82 | |
| 83 | const NO_KEY_REPEAT_MODIFIER_KEYS = ["ControlLeft", "ControlRight", "ShiftLeft", "ShiftRight", "MetaLeft", "MetaRight", "AltLeft", "AltRight", "AltGraph", "CapsLock", "Fn", "FnLock"]; |
| 84 | if (e.repeat && NO_KEY_REPEAT_MODIFIER_KEYS.includes(key)) return; |
| 85 | |
| 86 | if (await shouldRedirectKeyboardEventToBackend(e, dialogStore)) { |
| 87 | e.preventDefault(); |
| 88 | const modifiers = makeKeyboardModifiersBitfield(e); |
| 89 | editor.onKeyDown(key, modifiers, e.repeat); |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | if (get(dialogStore).visible && key === "Escape") { |
| 94 | editor.onDialogDismiss(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | export async function onKeyUp(e: KeyboardEvent, editor: EditorWrapper, dialogStore: DialogStore) { |
| 99 | const key = await getLocalizedScanCode(e); |
no test coverage detected