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