keys/hooks
Hooks
Per-hook API reference for @diffgazer/keys.
Keyboard and focus hooks split into two groups. Standalone hooks work anywhere — they take a ref, return handlers or run effects, and need no setup. Provider-backed hooks register through KeyboardProvider so they share one key dispatcher and participate in the scope stack; wrap your app (or the relevant subtree) in a provider to use them.
Standalone hooks
No provider required. Install the package (npm install @diffgazer/keys), or copy a standalone hook from the hosted registry (npx shadcn add https://r.b4r7.dev/r/keys/navigation.json).
Provider-backed hooks
Require KeyboardProvider. Package-only, since dispatch goes through the shared registry.
tsx
Choosing a navigation hook
- Movement within one list —
useNavigation(standalone, you attachonKeyDown) oruseScopedNavigation(provider-backed, scope-aware, noonKeyDown). - Movement between regions of a layout —
useFocusZone. - A row with inline actions —
useActionRowNavigation.
See the navigation, scopes, and focus zones guides for end-to-end patterns.