MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / handleKey

Function handleKey

packages/app-core/src/components/SettingsModal.tsx:4582–4605  ·  view source on GitHub ↗
(e: React.KeyboardEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

4580 }
4581
4582 const handleKey = (e: React.KeyboardEvent<HTMLInputElement>): void => {
4583 // While composing (IME), let the input own Enter/Arrows. (#183)
4584 if (isImeComposing(e)) return
4585 if (e.key === 'ArrowDown') {
4586 e.preventDefault()
4587 setActiveIdx((i) => (i + 1 >= items.length ? items.length - 1 : i + 1))
4588 } else if (e.key === 'ArrowUp') {
4589 e.preventDefault()
4590 setActiveIdx((i) => Math.max(0, i - 1))
4591 } else if (e.key === 'Enter') {
4592 e.preventDefault()
4593 const item = items[activeIdx]
4594 commit(item ?? null)
4595 } else if (e.key === 'Escape') {
4596 e.preventDefault()
4597 setOpen(false)
4598 } else if (e.key === 'Home') {
4599 e.preventDefault()
4600 setActiveIdx(0)
4601 } else if (e.key === 'End') {
4602 e.preventDefault()
4603 setActiveIdx(items.length - 1)
4604 }
4605 }
4606
4607 return (
4608 <div

Callers

nothing calls this directly

Calls 2

isImeComposingFunction · 0.90
commitFunction · 0.70

Tested by

no test coverage detected