Keyboard Focus & Navigation
RTXUI applications are fully keyboard-operable out of the box. This page describes what users can do with the keyboard, and how to control which elements participate.
Built-in keys
| Key | Behavior |
|---|---|
| Tab / Shift-Tab | Move focus through focusable elements in order. |
| Arrow keys / h j k l | Spatial navigation: focus the nearest focusable element in that direction; inside a scrollable, scroll. |
| Enter / Space | Activate the focused element (equivalent to a click). |
| PageUp / PageDown | Scroll the focused scrollable by a viewport. |
| Home / End | Jump the focused scrollable to its start or end. |
| Escape | Close the open <dialog>; otherwise exit the application. |
Component OnEvent overrides see events before these built-in behaviors, so custom key handling always wins.
Focus Control
To make any layout container (like a custom card or wrapper <div>) interactive and focusable, use these properties:
tabindex
Determines where the element fits in the sequential keyboard Tab navigation loop:
tabindex="0": The element is sequentially focusable (standard behavior).tabindex="-1": The element is focusable programmatically or via mouse clicks, but skipped when hitting Tab/Shift-Tab.tabindex="1"(or higher): Establishes custom sequential traversal order (lower positive values focus first).
<!-- Tab navigates to this div first, then the next -->
<div tabindex="1">First focusable zone</div>
<div tabindex="2">Second focusable zone</div>focusable Shorthand
Set focusable="true" as a clean shorthand for setting tabindex="0":
<div focusable="true" class="button">
Interactive Box
</div>Focusable items automatically capture keyboard events (ArrowLeft, Enter, etc.) and focus CSS pseudoclasses like :focus.
Live Demo
Spatial Navigation
In addition to sequential tab navigation (using Tab/Shift-Tab), RTXUI supports Spatial Navigation. By pressing the Arrow keys (or hjkl keys), RTXUI performs a geometric search in 2D screen space to find the closest focusable element in that direction and moves focus there. This provides a natural, game-like, or TV-like focus navigation experience for complex layouts.

