MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / onKeyDown

Function onKeyDown

frontend/src/utility-functions/input.ts:80–96  ·  view source on GitHub ↗
(e: KeyboardEvent, editor: EditorWrapper, dialogStore: DialogStore)

Source from the content-addressed store, hash-verified

78}
79
80export 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
98export async function onKeyUp(e: KeyboardEvent, editor: EditorWrapper, dialogStore: DialogStore) {
99 const key = await getLocalizedScanCode(e);

Callers 1

input.tsFile · 0.90

Calls 4

getLocalizedScanCodeFunction · 0.90
getFunction · 0.70

Tested by

no test coverage detected