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

Function parseKeybind

packages/app/src/context/command.tsx:110–153  ·  view source on GitHub ↗
(config: string)

Source from the content-addressed store, hash-verified

108}
109
110export function parseKeybind(config: string): Keybind[] {
111 if (!config || config === "none") return []
112
113 return config.split(",").map((combo) => {
114 const parts = combo.trim().toLowerCase().split("+")
115 const keybind: Keybind = {
116 key: "",
117 ctrl: false,
118 meta: false,
119 shift: false,
120 alt: false,
121 }
122
123 for (const part of parts) {
124 switch (part) {
125 case "ctrl":
126 case "control":
127 keybind.ctrl = true
128 break
129 case "meta":
130 case "cmd":
131 case "command":
132 keybind.meta = true
133 break
134 case "mod":
135 if (IS_MAC) keybind.meta = true
136 else keybind.ctrl = true
137 break
138 case "alt":
139 case "option":
140 keybind.alt = true
141 break
142 case "shift":
143 keybind.shift = true
144 break
145 default:
146 keybind.key = part
147 break
148 }
149 }
150
151 return keybind
152 })
153}
154
155export function matchKeybind(keybinds: Keybind[], event: KeyboardEvent): boolean {
156 const eventKey = normalizeKey(event.key)

Callers 5

signaturesFunction · 0.90
runFunction · 0.90
formatKeybindPartsFunction · 0.85
command.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected