Keyboard shortcuts across the Web UI, the App and the TUI
The file and the table
Part
Design
Action table
openprogram/state/keybinding_actions.json: every action once, with its id (area.verb, the TUI's ids kept), group, context, surfaces (web, desktop, tui), default keys (keysMac and keysWindows where a platform differs) and titles in both languages. Flags: reserved (shown, fixed), menu (a desktop menu accelerator), system (registered with the OS), hold (push to talk). The Web and the TUI import it; Python reads it to validate.
The person's file
<state dir>/keybindings.json, flat id → "keys" | ["keys"] | "none", only the changes. Every writer (the Worker route, /keybindings, the TUI recorder) rewrites the named entries and keeps the rest, $schema included; an unreadable file is never overwritten.
Key syntax
Modifiers and a key joined by +; a space separates the two keys of a chord. mod is ⌘ in a macOS window and Ctrl in every other window and every terminal; cmd is ⌘, or the Windows / Super key. mod++ is the plus key. Writers emit mod, so a recorded key works on the person's other computers.
Contexts
global, input, chat, queue, graph, webpage. Two contexts overlap when they are equal, when one is global (except the TUI's queue list), or for input and chat. Only overlapping contexts can clash.
Resolution
Case
Rule
The person binds a default's key
The default action in an overlapping context gives that key up; its other keys stay
Two of their own on one key
A conflict (a chord that starts with the other's key counts): both keep the key, both rows show it, and neither is dropped silently
Another surface's id
Left alone: the TUI ignores chat.find, a browser tab ignores webpage.*
Problems
Unknown id, reserved action, unreadable key, a chord on a menu or hold action, a chord without a modifier first, a key the surface reserves (Ctrl+C in the TUI): one warning each, the rest applies
Chords
Two keys at most, the first with a modifier, 1.5 s apart at most. While the first is pending only chords it starts can fire, so ⌘K ⌘T never also runs ⌘T's own action
Web registry
Part
Design
Registration
registerShortcut(id, handler, {capture?}). One document listener (after the focused element) and one window capture listener (for the palette and split view, which must beat an editor's own binding). Handlers run in table order; returning false passes the press on
Local handlers
The composer and the web page pane ask eventFires(id, event) inside their own handlers, so their keys follow the file too; hold-to-talk asks releasesHold on key-up
Matching
A stroke matches by event.code (US names) or event.key, so Option+U is still U and "?" matches the key that types it
Hints
Menus, tooltips, the run-graph key sheet and placeholders name an action id and draw its keys in force (⌘⇧T on macOS, Ctrl+Shift+T elsewhere); a hint for an action without a key is omitted
Store
GET / PUT /api/keybindings ({changes}, null resets an entry); the Worker watches the file and announces settings with the key keybindings, so the TUI, a hand edit and another window all reach every open page, and a page reads the file again only for that key or a reconnect, one read at a time
Settings page and recorder
Part
Design
Page
Settings → Keyboard shortcuts, built from the Settings page, section and row components; groups from the table, search over titles, ids and keys; Reset all in the header with no confirm (it is undoable by recording again)
Recording
Click the key: it records, every other shortcut is suspended. A key with a modifier waits 1 s for a second key (a chord); Esc or a click outside cancels
Conflict
On the control itself: "Used by X" with Replace and Cancel. Replace writes the action's key and removes it from the person's other binding; a default holder needs no entry
Per action
The ⋯ menu: record, add a second key, remove ("none"), reset. The reset button shows only on a changed row
/keybindings
A shared built-in. The Web composer opens the page; the TUI opens its list; elsewhere it lists, sets, adds, removes and resets in text
Desktop App and TUI
Surface
Design
App menu
The renderer sends the main process an accelerator per menu action and the strokes of the web page actions (keybindings:set). The menu, the tray and the system-wide screenshot key are rebuilt; the renderer leaves menu actions to the menu so a key never fires twice
Web pages
A native page has the keyboard, so main/keybindings.js matches its before-input-event against the page keys it was sent
TUI
esbuild bundles core.ts as it bundles the Vim state machine; mod is Ctrl, cmd is Super. The REPL follows the file; /keybindings and ? list the actions, Enter records a key with the same chord and conflict rules
Why this design
Decision
Reason
One flat file for every surface
Pi, oh-my-pi, opencode's TUI, Antigravity and DeepSeek Harness all keep a flat action → keys map; Codex and Claude Code nest by context. The flat map was already the TUI's file, and contexts stay in the table where nobody has to name them. One file instead of opencode's split (TUI file, desktop store) means a key changed in one place is changed everywhere
mod
opencode's desktop recorder writes mod and DeepSeek Harness writes primary; Electron's CmdOrCtrl is the same idea. Without it a file written on a Mac breaks on Windows
Chords
Codex (two strokes plus a leader), Claude Code (chords with a timeout) and opencode's leader support them; DeepSeek Harness, Pi and Gemini CLI do not. Two-key chords with a modifier first cover Codex's and Claude Code's form without a leader action to learn; menu accelerators and hold-to-talk cannot take one
A recorder, not only a file
Codex's /keymap, opencode's desktop Shortcuts page and DeepSeek Harness's settings recorder capture the key press; Claude Code and Antigravity open the file in an editor. Recording avoids spelling keys by hand and can show a conflict before it is saved
Conflicts on the control
Codex refuses with a dialog, opencode with a toast, DeepSeek Harness on save. The page shows who has the key on the row being edited and offers Replace, so the person decides in place; only the person's own clashing bindings (from a hand edit) stay as a visible conflict
Reset per action and all
DeepSeek Harness and opencode's desktop app have both; Codex has per action only, Antigravity says to delete the file. Reset all here has no confirmation, following the product's rule of asking only before destructive deletion
Warnings, not refusal
Codex refuses to start on a bad keymap; Claude Code and Pi warn and continue. A typo should not lock anyone out of any surface
Reserved Ctrl+C in the TUI
Claude Code reserves Ctrl+C and Ctrl+D because their stop and double-press exit are time-based; Ctrl+C here carries the same stop and exit, so it stays fixed
Lists and hints from the table
A hand-written list drifted from the handlers; generating the TUI's list, the Settings page and every hint from the table the handlers read keeps them equal, which is what Claude Code's and Codex's shortcut overlays do