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

Callers 2

SourceInspectorFunction · 0.90
hotkey.test.tsFile · 0.90

Calls 1

getHotkeyPermutationsFunction · 0.85

Tested by

no test coverage detected