From 8fc038e59b676d42910715633be5695208148bab Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Tue, 13 Jan 2026 13:58:13 +0800 Subject: [PATCH] feat: add Ctrl+Alt key remapping for browser-blocked shortcuts (#501) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browsers intercept Ctrl+W/T/N/Q, making them unusable in terminal. This adds Ctrl+Alt+ as an alternative that sends Ctrl+. - Ctrl+Alt+W → Ctrl+W (nano search, delete word) - Ctrl+Alt+T → Ctrl+T (transpose chars) - Ctrl+Alt+N → Ctrl+N (next line) - Ctrl+Alt+Q → Ctrl+Q (XON flow control) Fixes Termix-SSH/Support#407 --- .../apps/features/terminal/Terminal.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ui/desktop/apps/features/terminal/Terminal.tsx b/src/ui/desktop/apps/features/terminal/Terminal.tsx index dcee59c4..89c19b00 100644 --- a/src/ui/desktop/apps/features/terminal/Terminal.tsx +++ b/src/ui/desktop/apps/features/terminal/Terminal.tsx @@ -1349,6 +1349,24 @@ export const Terminal = forwardRef( return true; } + // Ctrl+Alt+ → Ctrl+ remapping for browser-blocked shortcuts + // Browsers intercept Ctrl+W/T/N/Q, so we use Ctrl+Alt as an alternative + if (e.ctrlKey && e.altKey && !e.metaKey && !e.shiftKey) { + const key = e.key.toLowerCase(); + const blockedKeys = ["w", "t", "n", "q"]; + if (blockedKeys.includes(key)) { + e.preventDefault(); + e.stopPropagation(); + const ctrlCode = key.charCodeAt(0) - 96; + if (webSocketRef.current?.readyState === 1) { + webSocketRef.current.send( + JSON.stringify({ type: "input", data: String.fromCharCode(ctrlCode) }), + ); + } + return false; + } + } + if (showAutocompleteRef.current) { if (e.key === "Escape") { e.preventDefault();