Documentation Index
Fetch the complete documentation index at: https://mintlify.com/RtlZeroMemory/Rezi/llms.txt
Use this file to discover all available pages before exploring further.
Keyboard Shortcuts
Patterns for implementing keyboard shortcuts, keybindings, and command palettes in Rezi applications.Problem
You need to:- Add global keyboard shortcuts (Ctrl+S, Ctrl+Q)
- Implement modal keymaps (Vim-style normal/insert modes)
- Support chord sequences (Ctrl+K Ctrl+S)
- Display shortcuts to users
- Build command palettes
Solution
Useapp.keys() for global bindings, app.modes() for contextual keymaps, and provide visual feedback with ui.kbd().
Global Keyboard Shortcuts
handler- Function to execute when shortcut is presseddescription- Metadata for help displaysctx- Access to app state and update function
Shorthand Syntax
For simple handlers without descriptions:Modal Keymaps (Vim-style)
Implement mode-based keybindings:- Mode isolation - Keys only active in specific modes
- Global overrides -
app.keys()bindings work in all modes - Dynamic mode switching -
app.setMode(modeName)
Chord Sequences
Multi-key sequences (e.g., Ctrl+K Ctrl+S):Chord Feedback
Show pending chord state to users:app.pendingChord contains the current partial chord (e.g., "ctrl+k" while waiting for the next key).
Displaying Shortcuts
Manual Shortcut Display
Auto-Generated Help
Display all registered keybindings:app.getBindings() returns all registered keybindings with descriptions for the current mode.
Command Palette
Searchable command interface:Context-Aware Shortcuts
Shortcuts that behave differently based on app state:Conditional Keybindings
Show different shortcuts based on state:Key Binding Priority
- Widget-level handlers - Inputs, buttons capture first
- Modal mode keys - Current mode’s
app.modes()bindings - Global keys -
app.keys()bindings - Fallback - Default system behavior
Overlay Item Shortcuts
Display shortcuts in dropdown menus:shortcut on dropdown items is display/filter only - you must register actual keybindings with app.keys().
Platform-Specific Modifiers
Common Patterns
Navigation Shortcuts
Debugging Shortcuts
Quick Actions
Best Practices
- Use standard conventions - Ctrl+S (save), Ctrl+Q (quit), Ctrl+Z (undo)
- Provide visual shortcuts - Display key hints with
ui.kbd() - Add descriptions - Enable auto-generated help with metadata
- Avoid conflicts - Don’t override browser/system shortcuts
- Use modes for complex apps - Separate editing/navigation contexts
- Show pending chords - Display
app.pendingChordfor feedback - Test keyboard navigation - Ensure all features are keyboard-accessible
- Document shortcuts - Provide a help modal with
app.getBindings() - Use command palette for discoverability - Searchable command list
- Platform-aware modifiers - Use Cmd on Mac, Ctrl elsewhere
Related
- Kbd Widget - Displaying keyboard shortcuts
- Command Palette Widget - Searchable commands
- Modal Patterns Recipe - Modal keyboard handling
- Focus Management - Focus navigation