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+k", "command": "commandPalette.toggle", "when": "!terminalFocus" },
27 { "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
28 { "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
29 { "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
30 { "key": "mod+o", "command": "editor.openFavorite" }
31]
32```
33
34For most up to date defaults, see [`DEFAULT_KEYBINDINGS` in `apps/server/src/keybindings.ts`](apps/server/src/keybindings.ts)
35
36## Configuration
37
38### Rule Shape
39
40Each entry supports:
41
42- `key` (required): shortcut string, like `mod+j`, `ctrl+k`, `cmd+shift+d`
43- `command` (required): action ID
44- `when` (optional): boolean expression controlling when the shortcut is active
45
46Invalid rules are ignored. Invalid config files are ignored. Warnings are logged by the server.
47
48### Available Commands
49
50- `terminal.toggle`: open/close terminal drawer
51- `terminal.split`: split terminal (in focused terminal context by default)
52- `terminal.new`: create new terminal (in focused terminal context by default)
53- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
54- `commandPalette.toggle`: open or close the global command palette
55- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
56- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
57- `editor.openFavorite`: open current project/worktree in the last-used editor
58- `script.{id}.run`: run a project script by id (for example `script.test.run`)
59
60### Key Syntax
61
62Supported modifiers:
63
64- `mod` (`cmd` on macOS, `ctrl` on non-macOS)
65- `cmd` / `meta`
66- `ctrl` / `control`
67- `shift`
68- `alt` / `option`
69
70Examples:
71
72- `mod+j`
73- `mod+shift+d`
74- `ctrl+l`
75- `cmd+k`
76
77### `when` Conditions
78
79Currently available context keys:
80
81- `terminalFocus`
82- `terminalOpen`
83
84Supported operators:
85
86- `!` (not)
87- `&&` (and)
88- `||` (or)
89- parentheses: `(` `)`
90
91Examples:
92
93- `"when": "terminalFocus"`
94- `"when": "terminalOpen && !terminalFocus"`
95- `"when": "terminalFocus || terminalOpen"`
96
97Unknown condition keys evaluate to `false`.
98
99### Precedence
100
101- Rules are evaluated in array order.
102- For a key event, the last rule where both `key` matches and `when` evaluates to `true` wins.
103- That means precedence is across commands, not only within the same command.