OpenProgram Docs

Keyboard shortcuts across the Web UI, the App and the TUI

keybinding_actions.jsonids, contexts, defaults keybindings.jsonthe person's changes core.tsresolve · match · plan Web registry TUI (bundled in) App main process Worker: GET / PUT /api/keybindings, /keybindingswrites the file, announces "settings"

The file and the table

PartDesign
Action tableopenprogram/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 syntaxModifiers 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.
Contextsglobal, 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

CaseRule
The person binds a default's keyThe default action in an overlapping context gives that key up; its other keys stay
Two of their own on one keyA 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 idLeft alone: the TUI ignores chat.find, a browser tab ignores webpage.*
ProblemsUnknown 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
ChordsTwo 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

PartDesign
RegistrationregisterShortcut(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 handlersThe 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
MatchingA stroke matches by event.code (US names) or event.key, so Option+U is still U and "?" matches the key that types it
HintsMenus, 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
StoreGET / 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

PartDesign
PageSettings → 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)
RecordingClick 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
ConflictOn 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 actionThe ⋯ menu: record, add a second key, remove ("none"), reset. The reset button shows only on a changed row
/keybindingsA 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

SurfaceDesign
App menuThe 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 pagesA native page has the keyboard, so main/keybindings.js matches its before-input-event against the page keys it was sent
TUIesbuild 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
DecisionReason
One flat file for every surfacePi, 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
modopencode'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
ChordsCodex (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 fileCodex'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 controlCodex 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 allDeepSeek 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 refusalCodex 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 TUIClaude 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 tableA 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

Implementation status

AreaItemState
SharedAction table, core.ts rules, /api/keybindings, /keybindingsBuilt
Web and AppRegistry for every shortcut, hints from bindings, Settings page with recorder, menu accelerators, page keys, screenshot keyBuilt
TUIShared core, chords, file follow, record from the listBuilt
Last updated · 2026-11-30