MCPcopy Create free account
hub / github.com/TanStack/devtools / isHotkeyCombinationPressed

Function isHotkeyCombinationPressed

packages/devtools/src/utils/hotkey.ts:50–66  ·  view source on GitHub ↗
(
  keys: Array<string>,
  hotkey: Array<KeyboardKey>,
)

Source from the content-addressed store, hash-verified

48
49/** Checks if the currently pressed keys match any of the hotkey permutations */
50export const isHotkeyCombinationPressed = (
51 keys: Array<string>,
52 hotkey: Array<KeyboardKey>,
53): boolean => {
54 const permutations = getHotkeyPermutations(hotkey)
55 const pressedKeys = keys.map((key) => key.toUpperCase())
56
57 return permutations.some(
58 (combo) =>
59 // every key in the combo must be pressed
60 combo.every((key) => pressedKeys.includes(String(key).toUpperCase())) &&
61 // and no extra keys beyond the combo
62 pressedKeys.every((key) =>
63 combo.map((k) => String(k).toUpperCase()).includes(key),
64 ),
65 )
66}

Callers 2

SourceInspectorFunction · 0.90
hotkey.test.tsFile · 0.90

Calls 1

getHotkeyPermutationsFunction · 0.85

Tested by

no test coverage detected