Skip to content

Commit 910bbf5

Browse files
committed
feat(terminal): add Cmd+Arrow and Shift+Enter keyboard shortcuts
- Cmd+Left/Right sends Home/End escape sequences (macOS) - Shift+Enter sends Alt+Enter for multi-line input in CLI agents
1 parent bc8a127 commit 910bbf5

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/components/TerminalView.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ export function TerminalView(props: TerminalViewProps) {
118118
});
119119

120120
term.attachCustomKeyEventHandler((e: KeyboardEvent) => {
121-
if (e.type !== 'keydown') return true;
121+
if (e.type !== 'keydown') {
122+
if (e.key === 'Enter' && e.shiftKey) return false;
123+
return true;
124+
}
122125

123126
// Let global app shortcuts pass through to the window handler
124127
if (matchesGlobalShortcut(e)) return false;
@@ -144,6 +147,25 @@ export function TerminalView(props: TerminalViewProps) {
144147
return false;
145148
}
146149

150+
// Shift+Enter → send as Alt+Enter (newline in CLI agents like Claude Code)
151+
if (e.key === 'Enter' && e.shiftKey) {
152+
e.preventDefault();
153+
enqueueInput('\x1b\r');
154+
return false;
155+
}
156+
157+
// macOS: Cmd+Left/Right → Home/End escape sequences
158+
if (isMac && e.metaKey && !e.altKey && !e.ctrlKey) {
159+
if (e.key === 'ArrowLeft') {
160+
enqueueInput('\x1b[H'); // Home
161+
return false;
162+
}
163+
if (e.key === 'ArrowRight') {
164+
enqueueInput('\x1b[F'); // End
165+
return false;
166+
}
167+
}
168+
147169
return true;
148170
});
149171

0 commit comments

Comments
 (0)