jatui

listNav

Keyboard navigation action for list-like UIs — j/k, vim motions, selection

A Svelte action that adds vim-style keyboard navigation to any list. Focus the list below and use j/k or arrow keys. Press Enter to select.

Interactive list

Click to focus, then: j/k move · Enter select · gg/G jump · Esc clear

Event log

No events yet — interact with the list

Usage

import { listNav } from 'jatui';

<div use:listNav={{
  onSelect: (el) => openDetail(el.dataset.navId),
  onEscape: () => closeDetail(),
}}>
  {#each items as item}
    <button data-nav-id={item.id}>{item.title}</button>
  {/each}
</div>

Key bindings

KeyAction
j / ↓Focus next item
k / ↑Focus previous item
Enter / SpaceSelect focused item
EscapeClear focus / selection
ggJump to first item
GJump to last item
{n}j / {n}kMove n items
Ctrl+D / Ctrl+UHalf-page down/up