Skip to content

Commit 4e1ce7e

Browse files
authored
Add Cmd+Left/Right as back/forward navigation shortcuts (#3176)
1 parent 036bece commit 4e1ce7e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/ui/src/features/command/keyboard-shortcuts.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export const SHORTCUTS = {
77
SHORTCUTS_SHEET: "mod+/",
88
GO_BACK: "mod+[",
99
GO_FORWARD: "mod+]",
10+
// Arrow variants must stay outside form fields/editors, where mod+left/right
11+
// means jump to line start/end - bind them without enableOnFormTags.
12+
GO_BACK_ALT: "mod+left",
13+
GO_FORWARD_ALT: "mod+right",
1014
TOGGLE_LEFT_SIDEBAR: "mod+b",
1115
TOGGLE_REVIEW_PANEL: "mod+shift+b",
1216
PREV_TASK: "mod+shift+[,ctrl+shift+tab",
@@ -115,12 +119,14 @@ export const KEYBOARD_SHORTCUTS: KeyboardShortcut[] = [
115119
keys: SHORTCUTS.GO_BACK,
116120
description: "Go back",
117121
category: "navigation",
122+
alternateKeys: SHORTCUTS.GO_BACK_ALT,
118123
},
119124
{
120125
id: "go-forward",
121126
keys: SHORTCUTS.GO_FORWARD,
122127
description: "Go forward",
123128
category: "navigation",
129+
alternateKeys: SHORTCUTS.GO_FORWARD_ALT,
124130
},
125131
{
126132
id: "toggle-left-sidebar",
@@ -253,6 +259,8 @@ function formatKey(key: string): string {
253259
if (k === "escape" || k === "esc") return "Esc";
254260
if (k === "up" || k === "arrowup") return "↑";
255261
if (k === "down" || k === "arrowdown") return "↓";
262+
if (k === "left" || k === "arrowleft") return "←";
263+
if (k === "right" || k === "arrowright") return "→";
256264
if (k === ",") return ",";
257265
if (k === "[") return "[";
258266
if (k === "]") return "]";

packages/ui/src/shell/GlobalEventHandlers.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ export function GlobalEventHandlers({
161161
useHotkeys(SHORTCUTS.SETTINGS, handleOpenSettings, globalOptions);
162162
useHotkeys(SHORTCUTS.GO_BACK, goBack, globalOptions);
163163
useHotkeys(SHORTCUTS.GO_FORWARD, goForward, globalOptions);
164+
// mod+left/right means jump to line start/end inside inputs and editors, so
165+
// the arrow variants skip enableOnFormTags/enableOnContentEditable.
166+
useHotkeys(SHORTCUTS.GO_BACK_ALT, goBack, { preventDefault: true });
167+
useHotkeys(SHORTCUTS.GO_FORWARD_ALT, goForward, { preventDefault: true });
164168
const handleToggleReview = useCallback(() => {
165169
if (!currentTaskId) return;
166170
const mode = getReviewMode(currentTaskId);

0 commit comments

Comments
 (0)