# Keyboard

Keyboard is the primary input for Life surfaces across web, desktop and terminal. Every interactive control is reachable and operable without a pointer. Touch gestures are out of scope for this release.

## Principles

- **Reachability:** Tab order follows visual reading order unless a documented roving pattern says otherwise.
- **No traps:** Focus must be escapable (WCAG 2.1.2). Overlays that capture Tab document the escape route (Escape, then a documented chord).
- **Visible focus:** Keyboard focus uses the standard ring only (`:focus-visible`, `--sv-focus-ring-*`). Pointer focus does not leave a ring behind.
- **Shortcuts:** Global shortcuts use **Mod** (⌘ on macOS, Ctrl on Windows/Linux). Single-character shortcuts are allowed only when remappable, focus-scoped, or inside a text field (WCAG 2.1.4 Character Key Shortcuts).

## Modifier convention

| Name | macOS | Windows / Linux |
| --- | --- | --- |
| Mod | ⌘ Command | Ctrl |
| Mod+Shift | ⌘⇧ | Ctrl+Shift |
| Alt | ⌥ Option | Alt |
| Shift | ⇧ Shift | Shift |

## Global shortcut map

| Shortcut | Action | Conflicts (VS Code / OS) |
| --- | --- | --- |
| Mod+K | Open command palette | VS Code: also "Show All Symbols" in some keymaps — product uses Mod+K for palette only in app chrome |
| `/` | Open slash menu in composer (when composer focused) | None when focus is in composer |
| `@` | Open mention / model menu in composer | None when focus is in composer |
| Mod+Enter | Send message / confirm primary action in focused region | VS Code: join lines in editor — only in composer or focused approval card |
| F6 | Cycle focus: sidebar → main → details panel | VS Code: peek definition in some bindings — app shell only |
| Shift+F6 | Reverse region cycle | Same as F6 |
| Escape | Close top overlay; restore focus to trigger; second Escape blurs composer menus | Universal — layered: menu → popover → dialog → route |
| `?` | Open keyboard shortcut help (when no text field focused) | Browser help on some pages — suppress in app shell |
| Mod+Shift+T | Focus toast region (actionable toasts) | VS Code: reopen closed editor — product reserves in webview |
| F8 | Focus next toast / status announcement region | VS Code: go to next problem — app chrome only |
| Shift+F10 / Menu key | Open context menu on focused row | Standard on lists |
| Mod+Shift+M | Exit terminal Tab trap (TerminalTab) | Varies — documented per TerminalTab |
| `[` / `]` or Alt+↑/↓ | Diff hunk navigation (ChangesTab) | Editor-specific when editor focused |

## Desktop app shortcuts

What the desktop app binds today. One table (`AppCommands`) feeds the command palette, the shortcuts sheet, the menu bar and the key handler, so a shortcut listed here works in all four. Some actions have a second binding, shown after "also".

| Group | Shortcut | Action |
| --- | --- | --- |
| Chat and session | ⌘N (also ⌘R, ⇧⌘N) | New chat |
| | ⌘O | Open folder |
| | ⌥⌘F | Toggle full screen |
| | ⇧⌘⌫ | Stop the running turn |
| | ⌘/ | Search models |
| | ⌘. | Cycle mode |
| | ⌥⌘[ and ⌥⌘] | Previous / next session |
| | ⇧⌘W | Close session |
| | ⇧⌘Space | Voice input |
| | ⇧⌘E | Export |
| | ⌘1 to ⌘9 | Open session N |
| Navigation and search | ⌘K (also ⇧⌘P) | Command palette |
| | ⌘P | Go to file |
| | ⌘F | Find in transcript |
| | ⇧⌘F | Search sessions |
| | ⌘[ and ⌘] | History back / forward |
| Pages and settings | ⇧⌘A | Control Center |
| | ⇧⌘R | Review PR |
| | ⌘, (also ⇧⌘J) | Settings |
| | ⇧⌘/ or ⌘\ | Shortcuts sheet |
| Layout and panes | ⌘B (also ⌘L) | Toggle sidebar |
| | ⌥⌘B | Toggle right panel |
| | ⌘J | Terminal |
| | ⇧⌘D | Diff |
| | ⇧⌘G | Git |
| | ⇧⌘V | Preview |
| | ⇧⌘I | Findings |
| Theme | commands only | System, Light, Dark |
| Shell-local | ⇧⌘Enter | Toggle pane focus |
| | Esc | Close the overview; un-focus a pane |
| | ⇧⌘X | Debug overlay |
| | Double-click title | Rename the session inline |
| | Swipe | History back / forward |

Inside components: the right-column tab strip roves with ← → Home End and only the active tab is a tab stop. The command palette uses ↑ ↓ Enter Esc, Tab / ⇧Tab to cycle scope, and Backspace on an empty scoped field to reset the scope. The folder picker uses ↑ ↓ Enter Esc. The Changes pane reference field uses Enter to apply and Esc to close.

**Not in the app (drift from the map above).** F6 region cycling, `?` help, ⇧⌘T and F8 toast focus, ⇧F10 context menu, Home / End / PgUp / PgDn in the palette, and the layered Escape order. The sidebar, popover menus and the changed-file tree have no arrow-key roving, Home / End or typeahead. Several row types draw no keyboard focus ring (see DESKTOP_SYNC.md). The Changes pane "Compare focuses the reference field" shortcut is documented but its wiring was not found.

## Focus management

**Open:** Move focus to the first focusable control in the layer (dialog: initial focus on primary safe control unless destructive).

**Close:** Escape closes the topmost layer. Focus returns to the element that opened it (menu button, dialog trigger). If the trigger is gone, focus moves to the nearest logical successor (WCAG 2.4.3).

**Roving tabindex:** Toolbars, menubars, tabs, and list options use roving `tabindex` (one tab stop; arrows move activation). Document per component.

**`aria-activedescendant`:** Combobox and listbox popups keep focus in the input while highlighting options — document in CommandPalette, SlashMenu, SkillsPicker, ModelMenu.

**Route change:** On navigation, move focus to the route heading (`h1`) or the main landmark skip target.

**Modal trap:** Sheet and Dialog trap Tab until dismissed; RightPaneShell traps only below `bp-compact` when overlaid.

## Layering (Escape order)

1. Typeahead / list highlight inside an open popup  
2. Popup (menu, combobox list)  
3. Non-modal popover  
4. Modal dialog / sheet  
5. Composer menu mode  
6. Blur composer  

## Related guidance

See also `foundations.md` (Focus), `ACCESSIBILITY.md`, and `patterns.md` (keyboard flows).

## Application hotkeys

Use `useHotkey`, `useHotkeys`, or `useHotkeySequence` from `@sarvam/life` to register shortcuts. Show the key combination with `formatForDisplay` and give each action a visible equivalent.

Keep application shortcuts out of text entry. The hotkey manager suppresses plain keys in editable targets by default. Guard modified shortcuts when they would interrupt typing in an input, textarea, or contenteditable element. Use `isEnterExemptTarget` when deciding if Enter should activate a dialog’s primary action.
