MCPcopy Create free account
hub / github.com/anomalyco/opencode / handleKey

Function handleKey

packages/ui/src/components/list.tsx:172–197  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

170 }
171
172 const handleKey = (e: KeyboardEvent) => {
173 setStore("mouseActive", false)
174 if (e.key === "Escape") return
175
176 const all = flat()
177 const selected = all.find((x) => props.key(x) === active())
178 const index = selected ? all.indexOf(selected) : -1
179 props.onKeyEvent?.(e, selected)
180
181 if (e.defaultPrevented) return
182
183 if (e.key === "Enter" && !e.isComposing) {
184 e.preventDefault()
185 if (selected) handleSelect(selected, index)
186 } else if (props.search) {
187 if (e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && (e.key === "n" || e.key === "p")) {
188 onKeyDown(e)
189 return
190 }
191 if (e.key === "ArrowDown" || e.key === "ArrowUp") {
192 onKeyDown(e)
193 }
194 } else {
195 onKeyDown(e)
196 }
197 }
198
199 props.ref?.({
200 onKeyDown: handleKey,

Callers

nothing calls this directly

Calls 6

setStoreFunction · 0.85
activeFunction · 0.70
handleSelectFunction · 0.70
onKeyDownFunction · 0.70
findMethod · 0.65
keyMethod · 0.45

Tested by

no test coverage detected