Most of the time you don't need to use this hook directly. Components like DropdownWrapper, Select, and MegaMenu already provide built-in keyboard navigation. Use this hook when building custom navigable interfaces that aren't covered by existing components.
Features
- Arrow key navigation (up, down, left, right)
- Support for row, column, and grid layouts
- Automatic focus management
- Enter/Space key selection
- Optional wrapping at boundaries
- Visual focus highlighting
- ARIA-compliant accessibility
Basic usage
Grid layout
Row layout
API Reference
Return value
Keyboard controls
- Arrow Up: Move focus up (column/grid)
- Arrow Down: Move focus down (column/grid)
- Arrow Left: Move focus left (row/grid)
- Arrow Right: Move focus right (row/grid)
- Enter/Space: Select focused item
- Home: Focus first item
- End: Focus last item
Styling focused items
Accessibility
- Focus visibility with visual indicators
- ARIA roles and attributes
- Keyboard event handling
- Focus trap within container
Used in components
- EmojiPicker
- Dropdown
- Select
- ContextMenu
- MegaMenu