MCPcopy Index your code
hub / github.com/anomalyco/opencode / matchKeybind

Function matchKeybind

packages/app/src/context/command.tsx:155–171  ·  view source on GitHub ↗
(keybinds: Keybind[], event: KeyboardEvent)

Source from the content-addressed store, hash-verified

153}
154
155export function matchKeybind(keybinds: Keybind[], event: KeyboardEvent): boolean {
156 const eventKey = normalizeKey(event.key)
157
158 for (const kb of keybinds) {
159 const keyMatch = kb.key === eventKey
160 const ctrlMatch = kb.ctrl === (event.ctrlKey || false)
161 const metaMatch = kb.meta === (event.metaKey || false)
162 const shiftMatch = kb.shift === (event.shiftKey || false)
163 const altMatch = kb.alt === (event.altKey || false)
164
165 if (keyMatch && ctrlMatch && metaMatch && shiftMatch && altMatch) {
166 return true
167 }
168 }
169
170 return false
171}
172
173function displayKeybindParts(kb: Keybind, t?: (key: KeyLabel) => string) {
174 const parts: string[] = []

Callers 2

runFunction · 0.90

Calls 1

normalizeKeyFunction · 0.70

Tested by

no test coverage detected