MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / onKey

Function onKey

ui/src/components/InboxSidebar.tsx:69–77  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

67 // Keyboard nav — j/k move within the currently-displayed order.
68 useEffect(() => {
69 function onKey(e: KeyboardEvent) {
70 if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return
71 if (e.metaKey || e.ctrlKey || e.altKey) return
72 if (e.key !== 'j' && e.key !== 'k') return
73 if (ordered.length === 0) return
74 const idx = ordered.findIndex((x) => x.id === selectedId)
75 const next = e.key === 'j' ? Math.min(ordered.length - 1, idx + 1) : Math.max(0, idx - 1)
76 if (next !== idx && ordered[next]) selectAndRead(ordered[next]!.id)
77 }
78 window.addEventListener('keydown', onKey)
79 return () => window.removeEventListener('keydown', onKey)
80 // eslint-disable-next-line react-hooks/exhaustive-deps

Callers

nothing calls this directly

Calls 1

selectAndReadFunction · 0.85

Tested by

no test coverage detected