MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / handleKeydown

Function handleKeydown

frontend/src/hooks/useKeyboardEvents.ts:7–27  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

5 fn: Function
6) {
7 const handleKeydown = (e: KeyboardEvent) => {
8 const ctrl = keyCombination.ctrl && (e.ctrlKey || e.metaKey);
9 const alt = keyCombination.alt && e.altKey;
10 const key = keyCombination.caseSensitive
11 ? keyCombination.key
12 : keyCombination.key.toLocaleLowerCase();
13
14 const eKey = keyCombination.caseSensitive ? e.key : e.key.toLocaleLowerCase();
15
16 const isCombo = () => {
17 if (ctrl && alt) return eKey === key;
18 if (ctrl) return eKey === key;
19 if (alt) return eKey === key;
20 return false;
21 };
22
23 if (isCombo()) {
24 e.preventDefault();
25 fn();
26 }
27 };
28
29 const removeKeydownListener = () => {
30 document.removeEventListener("keydown", handleKeydown);

Callers

nothing calls this directly

Calls 2

isComboFunction · 0.85
fnFunction · 0.85

Tested by

no test coverage detected