Keyboard Shortcuts & Command Palette
Relevant source files
The following files were used as context for generating this wiki page:
The Keyboard Shortcuts and Command Palette system in Keynobi provides a unified interface for triggering application actions via global hotkeys or a searchable command interface. This system is central to the "AI-first" and developer-centric design philosophy of the project, ensuring that every significant user action is registered in a central registry to remain discoverable and accessible.
The architecture relies on a "Keybindings = Actions" rule. Shortcuts that bypass the action registry are considered invisible to the command palette and are discouraged. Most actions are registered in the root App.tsx component during the mounting phase, linking keyboard combinations to specific service calls or UI state transitions.
Sources: AGENTS.md:23-25, src/App.tsx:64-75, README.md:144-156
Architecture and Registration
The system is built on two primary pillars: a keybindings manager that handles raw DOM events and an action-registry that manages the metadata for the Command Palette.
Unified Registration Logic
To ensure consistency, the application uses a helper function registerKeyAndAction. This function simultaneously registers a keyboard listener and adds the action to the searchable registry.
This unified approach ensures that the shortcut description shown in the UI matches the actual logic executed by the hotkey.
Sources: src/App.tsx:64-85, AGENTS.md:23-25
Implementation Detail: registerKeyAndAction
The registration utility accepts an object containing the ID, key combination (including modifiers like metaKey, shiftKey, and altKey), a label, a category, and the execution callback.
function registerKeyAndAction(opts: {
id: string;
key: string;
metaKey?: boolean;
shiftKey?: boolean;
altKey?: boolean;
label: string;
category: ActionCategory;
action: () => void;
}) {
registerKeybinding({
key: opts.key,
// ... modifiers and action
});
registerAction({
id: opts.id,
label: opts.label,
shortcut: formatShortcut(opts),
action: opts.action,
});
}
Sources: src/App.tsx:64-85
Global Keyboard Shortcuts
Keynobi maps specific keyboard combinations to high-frequency development tasks. These range from UI navigation to build orchestration.
Shortcut Definitions
The following table summarizes the primary shortcuts defined in the application registry:
| Category | Action | Shortcut | File |
|---|---|---|---|
| General | Command Palette | Cmd+Shift+P | src/App.tsx:142 |
| General | Settings | Cmd+, | src/App.tsx:114 |
| Build | Run App | Cmd+R | src/App.tsx:145 |
| Build | Build Only | Cmd+Shift+R | src/App.tsx:154 |
| View | Open Build Panel | Cmd+1 | src/App.tsx:126 |
| View | Open Logcat Panel | Cmd+2 | src/App.tsx:127 |
| View | Toggle Device Sidebar | Cmd+3 | src/App.tsx:128 |
| View | Toggle Project Sidebar | Cmd+B | src/App.tsx:129 |
| View | Health Center | Cmd+Shift+H | src/App.tsx:125 |
Sources: src/App.tsx:114-190, README.md:255-271
Context and Input Handling
The keybinding system includes "context-aware" logic. By default, most keybindings are suppressed when the user is focused on an INPUT or TEXTAREA element to prevent interference with typing. However, specific bindings can be registered with a global context, which allows them to fire regardless of the focused element.
Sources: src/lib/keybindings.test.ts:133-146
Command Palette Interface
The Command Palette, triggered via Cmd+Shift+P, serves as the central hub for discovering and executing all registered actions.
Data Flow
When a user opens the palette, it queries the action-registry for all items. It supports fuzzy matching and organizes results by category (e.g., "Build", "View", "File").
Specialized Actions
Some actions are exclusive to the Command Palette or lack a default physical shortcut. These include:
- Cancel Build: Aborts the current Gradle task.
- Clean Project: Executes the
./gradlew cleantask. - Copy MCP Setup Command: Copies the command string required to register Keynobi as an MCP server with Claude Code.
- Project App Info: Opens a modal to edit
versionNameandversionCode.
Sources: src/App.tsx:163-180, README.md:273-276
Debugging and Testing
The keybinding system is validated through a comprehensive test suite that ensures proper deduplication and event handling.
Keybinding Logic Verification
The system enforces strict deduplication. If a new binding is registered with a key combination that already exists, it replaces the previous binding to ensure predictable behavior.
| Test Case | Expected Outcome |
|---|---|
| Register duplicate combo | Second registration replaces the first |
| Register same description, different combo | Both bindings coexist independently |
| Dispatch from Input | Binding is skipped unless context is 'global' |
Sources: src/lib/keybindings.test.ts:70-90, src/lib/keybindings.test.ts:133-146
Debug-Only Actions
In development mode (import.meta.env.DEV), the registry includes additional actions for telemetry testing, such as "Send test web Sentry event" and "Send test native (Rust) Sentry event".
Sources: src/App.tsx:132-140
Conclusion
The Keyboard Shortcuts and Command Palette system in Keynobi provides a streamlined, keyboard-first workflow for Android developers. By centralizing all operations into a single action registry and providing a unified registration utility, the application ensures that every feature—from building APKs to managing logcat buffers—is easily discoverable and accessible via low-latency interactions.