Open History to see the last commit
1# Keybindings
2
3T3 Code reads keybindings from:
4
5- `~/.t3/keybindings.json`
6
7The file must be a JSON array of rules:
8
9```json
10[
11 { "key": "mod+g", "command": "terminal.toggle" },
12 { "key": "mod+shift+g", "command": "terminal.new", "when": "terminalFocus" }
13]
14```
15
16See the full schema for more details: [`packages/contracts/src/keybindings.ts`](../../packages/contracts/src/keybindings.ts)
17
18## Defaults
19
20```json
21[
22 { "key": "mod+j", "command": "terminal.toggle" },
23 { "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
24 { "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
25 { "key": "mod+w", "command": "terminal.close", "when": "terminalFocus" },
26 { "key": "mod+shift+j", "command": "preview.toggle" },
27 { "key": "mod+r", "command": "preview.refresh", "when": "previewFocus" },
28 { "key": "mod+l", "command": "preview.focusUrl", "when": "previewFocus" },
29 { "key": "mod+=", "command": "preview.zoomIn", "when": "previewFocus" },
30 { "key": "mod+-", "command": "preview.zoomOut", "when": "previewFocus" },
31 { "key": "mod+0", "command": "preview.resetZoom", "when": "previewFocus" },
32 { "key": "mod+k", "command": "commandPalette.toggle", "when": "!terminalFocus" },
33 { "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
34 { "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
35 { "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
36 { "key": "mod+o", "command": "editor.openFavorite" }
37]
38```
39
40For most up to date defaults, see [`DEFAULT_KEYBINDINGS` in `apps/server/src/keybindings.ts`](../../apps/server/src/keybindings.ts)
41
42## Configuration
43
44### Rule Shape
45
46Each entry supports:
47
48- `key` (required): shortcut string, like `mod+j`, `ctrl+k`, `cmd+shift+d`
49- `command` (required): action ID
50- `when` (optional): boolean expression controlling when the shortcut is active
51
52Invalid rules are ignored. Invalid config files are ignored. Warnings are logged by the server.
53
54### Available Commands
55
56- `terminal.toggle`: open/close terminal drawer
57- `terminal.split`: split terminal (in focused terminal context by default)
58- `terminal.new`: create new terminal (in focused terminal context by default)
59- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
60- `preview.toggle`: open/close the in-app browser preview panel (desktop app only)
61- `preview.refresh`: reload the active preview tab (in focused preview context by default)
62- `preview.focusUrl`: focus the URL input of the preview panel (in focused preview context by default)
63- `preview.zoomIn`: zoom the preview viewport in one step (in focused preview context by default)
64- `preview.zoomOut`: zoom the preview viewport out one step (in focused preview context by default)
65- `preview.resetZoom`: reset the preview zoom to 100% (in focused preview context by default)
66- `commandPalette.toggle`: open or close the global command palette
67- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
68- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
69- `editor.openFavorite`: open current project/worktree in the last-used editor
70- `script.{id}.run`: run a project script by id (for example `script.test.run`)
71
72### Key Syntax
73
74Supported modifiers:
75
76- `mod` (`cmd` on macOS, `ctrl` on non-macOS)
77- `cmd` / `meta`
78- `ctrl` / `control`
79- `shift`
80- `alt` / `option`
81
82Examples:
83
84- `mod+j`
85- `mod+shift+d`
86- `ctrl+l`
87- `cmd+k`
88
89### `when` Conditions
90
91Currently available context keys:
92
93- `terminalFocus`
94- `terminalOpen`
95- `previewFocus`
96- `previewOpen`
97
98Supported operators:
99
100- `!` (not)
101- `&&` (and)
102- `||` (or)
103- parentheses: `(` `)`
104
105Examples:
106
107- `"when": "terminalFocus"`
108- `"when": "terminalOpen && !terminalFocus"`
109- `"when": "terminalFocus || terminalOpen"`
110
111Unknown condition keys evaluate to `false`.
112
113### Precedence
114
115- Rules are evaluated in array order.
116- For a key event, the last rule where both `key` matches and `when` evaluates to `true` wins.
117- That means precedence is across commands, not only within the same command.