diff --git a/src/App.tsx b/src/App.tsx index 6680c17..d55f58c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -119,17 +119,23 @@ export default function App() { window.addEventListener("beforeunload", () => flushPersistedState()); - // Shift+ArrowUp / Shift+ArrowDown: cycle tabs. Registered in the capture - // phase so it fires before xterm's textarea handler — otherwise xterm - // swallows the event (translates it to a PTY escape sequence) and the tab - // bar only responds after the user clicks the sidebar to move focus. - // Skipped when focus is in a real text input / passthrough mode so the key - // can still extend selection / be forwarded to the remote agent. + // Shift+ArrowUp/Down and Ctrl+PageUp/PageDown: cycle tabs. Registered in + // the capture phase so it fires before xterm's textarea handler — + // otherwise xterm swallows the event (translates it to a PTY escape + // sequence) and the tab bar only responds after the user clicks the + // sidebar to move focus. Skipped when focus is in a real text input / + // passthrough mode so the key can still extend selection / be forwarded + // to the remote agent. window.addEventListener( "keydown", (e) => { - if (!e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return; - if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return; + const shiftCombo = + e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey && + (e.key === "ArrowUp" || e.key === "ArrowDown"); + const ctrlCombo = + e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && + (e.key === "PageUp" || e.key === "PageDown"); + if (!shiftCombo && !ctrlCombo) return; if (isActiveTabPassthrough()) return; // xterm's own input is a hidden