Skip to content

Commit 54b307b

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 9ce6abe commit 54b307b

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
@@ -171,7 +171,10 @@ export function TerminalView(props: TerminalViewProps) {
171171
});
172172

173173
term.attachCustomKeyEventHandler((e: KeyboardEvent) => {
174-
if (e.type !== 'keydown') return true;
174+
if (e.type !== 'keydown') {
175+
if (e.key === 'Enter' && e.shiftKey) return false;
176+
return true;
177+
}
175178

176179
// Let global app shortcuts pass through to the window handler
177180
if (matchesGlobalShortcut(e)) return false;
@@ -197,6 +200,25 @@ export function TerminalView(props: TerminalViewProps) {
197200
return false;
198201
}
199202

203+
// Shift+Enter → send as Alt+Enter (newline in CLI agents like Claude Code)
204+
if (e.key === 'Enter' && e.shiftKey) {
205+
e.preventDefault();
206+
enqueueInput('\x1b\r');
207+
return false;
208+
}
209+
210+
// CmdOrCtrl+Left/Right → Home/End escape sequences
211+
if ((isMac ? e.metaKey : e.ctrlKey) && !e.altKey && !(isMac ? e.ctrlKey : e.metaKey)) {
212+
if (e.key === 'ArrowLeft') {
213+
enqueueInput('\x1b[H'); // Home
214+
return false;
215+
}
216+
if (e.key === 'ArrowRight') {
217+
enqueueInput('\x1b[F'); // End
218+
return false;
219+
}
220+
}
221+
200222
return true;
201223
});
202224

0 commit comments

Comments
 (0)