( input: string, key: Key, target: ParsedKeystroke, )
| 84 | * The display text will show platform-appropriate names (opt on macOS, alt elsewhere). |
| 85 | */ |
| 86 | export 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. |
no test coverage detected