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

Function handleKeyDown

packages/app/src/context/command.tsx:372–393  ·  view source on GitHub ↗
(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

370 }
371
372 const handleKeyDown = (event: KeyboardEvent) => {
373 if (suspended() || dialog.active) return
374
375 const sig = signatureFromEvent(event)
376 const isPalette = palette().has(sig)
377 const option = keymap().get(sig)
378 const modified = event.ctrlKey || event.metaKey || event.altKey
379 const isTab = event.key === "Tab"
380
381 if (isEditableTarget(event.target) && !isPalette && !isAllowedEditableKeybind(option?.id) && !modified && !isTab)
382 return
383
384 if (isPalette) {
385 event.preventDefault()
386 showPalette()
387 return
388 }
389
390 if (!option) return
391 event.preventDefault()
392 option.onSelect?.("keybind")
393 }
394
395 onMount(() => {
396 makeEventListener(document, "keydown", handleKeyDown)

Callers

nothing calls this directly

Calls 6

suspendedFunction · 0.85
signatureFromEventFunction · 0.85
isAllowedEditableKeybindFunction · 0.85
showPaletteFunction · 0.85
isEditableTargetFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected