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

Function matchesEvent

web/lib/keyParser.ts:33–49  ·  view source on GitHub ↗
(parsed: ParsedKey, e: KeyboardEvent)

Source from the content-addressed store, hash-verified

31 * Test whether a KeyboardEvent matches a parsed key definition.
32 */
33export function matchesEvent(parsed: ParsedKey, e: KeyboardEvent): boolean {
34 // On Mac, `mod` maps to metaKey; on Win/Linux it maps to ctrlKey
35 const expectedMeta = isMac ? parsed.mod : false;
36 const expectedCtrl = isMac ? parsed.ctrl : parsed.mod || parsed.ctrl;
37
38 if (e.metaKey !== expectedMeta) return false;
39 if (e.ctrlKey !== expectedCtrl) return false;
40 if (e.altKey !== parsed.alt) return false;
41
42 // For alphanumeric keys, enforce the shift modifier check explicitly.
43 // For symbol characters (?, /, comma, etc.) shift is implicit in the key value,
44 // so we skip the shift check and just match on e.key.
45 const keyIsAlphanumeric = /^[a-z0-9]$/.test(parsed.key);
46 if (keyIsAlphanumeric && e.shiftKey !== parsed.shift) return false;
47
48 return e.key.toLowerCase() === parsed.key;
49}
50
51/**
52 * Format a key combo string for display.

Callers 1

handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected