MCPcopy Index your code
hub / github.com/codeaashu/claude-code / matchesKeystroke

Function matchesKeystroke

src/keybindings/match.ts:86–105  ·  view source on GitHub ↗
(
  input: string,
  key: Key,
  target: ParsedKeystroke,
)

Source from the content-addressed store, hash-verified

84 * The display text will show platform-appropriate names (opt on macOS, alt elsewhere).
85 */
86export function matchesKeystroke(
87 input: string,
88 key: Key,
89 target: ParsedKeystroke,
90): boolean {
91 const keyName = getKeyName(input, key)
92 if (keyName !== target.key) return false
93
94 const inkMods = getInkModifiers(key)
95
96 // QUIRK: Ink sets key.meta=true when escape is pressed (see input-event.ts).
97 // This is a legacy behavior from how escape sequences work in terminals.
98 // We need to ignore the meta modifier when matching the escape key itself,
99 // otherwise bindings like "escape" (without modifiers) would never match.
100 if (key.escape) {
101 return modifiersMatch({ ...inkMods, meta: false }, target)
102 }
103
104 return modifiersMatch(inkMods, target)
105}
106
107/**
108 * Check if Ink's Key + input matches a parsed binding's first keystroke.

Callers 1

matchesBindingFunction · 0.85

Calls 3

getKeyNameFunction · 0.85
getInkModifiersFunction · 0.85
modifiersMatchFunction · 0.85

Tested by

no test coverage detected