Skip to content

Commit df50192

Browse files
committed
refactor(keyboard): group keybindings by action
Reorganized default_bindings() to group keybindings that execute the same action next to each other. This improves readability and makes it easier to see all ways to trigger a command. For example, all variants of line-start navigation (home, cmd+left) are now grouped together, as are word deletion (ctrl+w, alt+backspace, alt+d).
1 parent ae85bd8 commit df50192

1 file changed

Lines changed: 52 additions & 33 deletions

File tree

src-rust/crates/core/src/keybindings.rs

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,11 @@ pub fn default_bindings() -> Vec<ParsedBinding> {
170170
("alt+h", "openHelp", KeyContext::Global),
171171

172172
// ========== CHAT / INPUT CONTEXT ==========
173+
// Message submission
173174
("enter", "submit", KeyContext::Chat),
174-
("up", "historyPrev", KeyContext::Chat),
175-
("down", "historyNext", KeyContext::Chat),
176-
("shift+tab", "reverseIndent", KeyContext::Chat),
177-
("pageup", "scrollUp", KeyContext::Chat),
178-
("pagedown", "scrollDown", KeyContext::Chat),
179-
("tab", "indent", KeyContext::Chat),
175+
("ctrl+m", "sendMessage", KeyContext::Chat),
176+
177+
// Newline insertion (Shift+Enter / Ctrl+J for multi-line composing)
180178
("shift+enter", "newline", KeyContext::Chat),
181179
// Fallback for terminals that do not support the kitty keyboard protocol
182180
// (e.g. Terminal.app, older iTerm2, Windows Terminal, or SSH sessions).
@@ -188,41 +186,62 @@ pub fn default_bindings() -> Vec<ParsedBinding> {
188186
// fallback is not needed there. Keep it as a compatibility belt-and-braces
189187
// for terminals that do not support the protocol.
190188
("ctrl+j", "newline", KeyContext::Chat),
189+
190+
// Line start/end navigation
191191
("home", "goLineStart", KeyContext::Chat),
192-
("end", "goLineEnd", KeyContext::Chat),
193192
("cmd+left", "goLineStart", KeyContext::Chat),
193+
("end", "goLineEnd", KeyContext::Chat),
194194
("cmd+right", "goLineEnd", KeyContext::Chat),
195+
("ctrl+e", "goLineEnd", KeyContext::Chat),
196+
197+
// Word navigation
195198
("ctrl+left", "moveWordBackward", KeyContext::Chat),
196199
("ctrl+right", "moveWordForward", KeyContext::Chat),
197200

198-
// Text Editing (Emacs-style) + app shortcuts
199-
("ctrl+a", "openModelPicker", KeyContext::Chat),
200-
("ctrl+e", "goLineEnd", KeyContext::Chat),
201-
("ctrl+h", "deleteCharBefore", KeyContext::Chat),
202-
("ctrl+k", "openCommandPalette", KeyContext::Chat),
203-
("ctrl+u", "killToStart", KeyContext::Chat),
201+
// Word deletion
204202
("ctrl+w", "killWord", KeyContext::Chat),
205-
("alt+d", "deleteWord", KeyContext::Chat),
206203
("alt+backspace", "killWord", KeyContext::Chat),
204+
("alt+d", "deleteWord", KeyContext::Chat),
207205

208-
// New Text Editing & Navigation
209-
("ctrl+m", "sendMessage", KeyContext::Chat),
206+
// Character/line deletion
207+
("ctrl+h", "deleteCharBefore", KeyContext::Chat),
208+
("ctrl+u", "killToStart", KeyContext::Chat),
210209
("ctrl+l", "clearLine", KeyContext::Chat),
211-
("ctrl+.", "jumpToNextError", KeyContext::Chat),
212-
("ctrl+shift+.", "jumpToPreviousError", KeyContext::Chat),
213-
("alt+left", "previousMessage", KeyContext::Chat),
214-
("alt+right", "nextMessage", KeyContext::Chat),
210+
211+
// History navigation
212+
("up", "historyPrev", KeyContext::Chat),
215213
("ctrl+o", "historyPrev", KeyContext::Chat),
214+
("down", "historyNext", KeyContext::Chat),
216215
("ctrl+i", "historyNext", KeyContext::Chat),
217216

217+
// Message navigation
218+
("alt+left", "previousMessage", KeyContext::Chat),
219+
("alt+right", "nextMessage", KeyContext::Chat),
220+
221+
// Error/issue navigation
222+
("ctrl+.", "jumpToNextError", KeyContext::Chat),
223+
("ctrl+shift+.", "jumpToPreviousError", KeyContext::Chat),
224+
218225
// Searching
219226
("ctrl+f", "findInMessage", KeyContext::Chat),
220227
("ctrl+shift+f", "globalSearch", KeyContext::Chat),
221-
("ctrl+g", "goToLine", KeyContext::Chat),
222228
("f3", "findNext", KeyContext::Chat),
223229
("ctrl+]", "findNext", KeyContext::Chat),
224230
("shift+f3", "findPrev", KeyContext::Chat),
225231
("ctrl+[", "findPrev", KeyContext::Chat),
232+
("ctrl+g", "goToLine", KeyContext::Chat),
233+
234+
// Indentation
235+
("tab", "indent", KeyContext::Chat),
236+
("shift+tab", "reverseIndent", KeyContext::Chat),
237+
238+
// Scrolling
239+
("pageup", "scrollUp", KeyContext::Chat),
240+
("pagedown", "scrollDown", KeyContext::Chat),
241+
242+
// App shortcuts
243+
("ctrl+a", "openModelPicker", KeyContext::Chat),
244+
("ctrl+k", "openCommandPalette", KeyContext::Chat),
226245

227246
// ========== CONFIRMATION DIALOGS ==========
228247
("y", "yes", KeyContext::Confirmation),
@@ -241,10 +260,10 @@ pub fn default_bindings() -> Vec<ParsedBinding> {
241260
("pagedown", "pageDown", KeyContext::Help),
242261

243262
// ========== HISTORY SEARCH ==========
244-
("enter", "select", KeyContext::HistorySearch),
245-
("escape", "cancel", KeyContext::HistorySearch),
246263
("up", "prevResult", KeyContext::HistorySearch),
247264
("down", "nextResult", KeyContext::HistorySearch),
265+
("enter", "select", KeyContext::HistorySearch),
266+
("escape", "cancel", KeyContext::HistorySearch),
248267
("tab", "togglePreview", KeyContext::HistorySearch),
249268

250269
// ========== TRANSCRIPT / MESSAGE SELECTION ==========
@@ -260,20 +279,20 @@ pub fn default_bindings() -> Vec<ParsedBinding> {
260279
// ========== MESSAGE SELECTOR OVERLAY ==========
261280
("up", "prevMessage", KeyContext::MessageSelector),
262281
("down", "nextMessage", KeyContext::MessageSelector),
282+
("k", "prevMessage", KeyContext::MessageSelector),
283+
("j", "nextMessage", KeyContext::MessageSelector),
263284
("enter", "select", KeyContext::MessageSelector),
264285
("escape", "cancel", KeyContext::MessageSelector),
265-
("j", "nextMessage", KeyContext::MessageSelector),
266-
("k", "prevMessage", KeyContext::MessageSelector),
267286

268287
// ========== THEME & MODEL PICKERS ==========
269288
("up", "prev", KeyContext::ThemePicker),
270289
("down", "next", KeyContext::ThemePicker),
290+
("k", "prev", KeyContext::ThemePicker),
291+
("j", "next", KeyContext::ThemePicker),
271292
("pageup", "pageUp", KeyContext::ThemePicker),
272293
("pagedown", "pageDown", KeyContext::ThemePicker),
273294
("enter", "select", KeyContext::ThemePicker),
274295
("escape", "cancel", KeyContext::ThemePicker),
275-
("j", "next", KeyContext::ThemePicker),
276-
("k", "prev", KeyContext::ThemePicker),
277296

278297
// ========== TASK LIST ==========
279298
("up", "prevTask", KeyContext::Task),
@@ -285,22 +304,22 @@ pub fn default_bindings() -> Vec<ParsedBinding> {
285304
// ========== DIFF DIALOG ==========
286305
("up", "prevDiff", KeyContext::DiffDialog),
287306
("down", "nextDiff", KeyContext::DiffDialog),
288-
("pageup", "pageUp", KeyContext::DiffDialog),
289-
("pagedown", "pageDown", KeyContext::DiffDialog),
307+
("a", "acceptDiff", KeyContext::DiffDialog),
290308
("enter", "acceptDiff", KeyContext::DiffDialog),
291-
("escape", "rejectDiff", KeyContext::DiffDialog),
292309
("r", "rejectDiff", KeyContext::DiffDialog),
293-
("a", "acceptDiff", KeyContext::DiffDialog),
310+
("escape", "rejectDiff", KeyContext::DiffDialog),
311+
("pageup", "pageUp", KeyContext::DiffDialog),
312+
("pagedown", "pageDown", KeyContext::DiffDialog),
294313

295314
// ========== MODAL SELECT (Generic) ==========
296315
("up", "prev", KeyContext::Select),
297316
("down", "next", KeyContext::Select),
317+
("k", "prev", KeyContext::Select),
318+
("j", "next", KeyContext::Select),
298319
("pageup", "pageUp", KeyContext::Select),
299320
("pagedown", "pageDown", KeyContext::Select),
300321
("enter", "select", KeyContext::Select),
301322
("escape", "cancel", KeyContext::Select),
302-
("j", "next", KeyContext::Select),
303-
("k", "prev", KeyContext::Select),
304323
("/", "search", KeyContext::Select),
305324

306325
// ========== PLUGIN & ATTACHMENTS ==========

0 commit comments

Comments
 (0)