The best way to control Claude Code, Codex and more from any computer or phone
Ignore non-keydown terminal shortcuts
- guard terminal clear/navigation shortcut handlers to only process `keydown` - add tests verifying `keyup` events are ignored
Julius Marminge committed
Feb 15, 2026 at 17:02 UTC
f864ef189d5def4cb2ae3f34cc461f13b3fc5a00
2 files changed
+22
apps/web/src/keybindings.test.ts
+13
@@ -325,6 +325,10 @@ describe("isTerminalClearShortcut", () => {
325
it("matches Cmd+K on macOS", () => {
326
assert.isTrue(isTerminalClearShortcut(event({ key: "k", metaKey: true }), "MacIntel"));
327
});
328
+
329
+ it("ignores non-keydown events", () => {
330
+ assert.isFalse(isTerminalClearShortcut(event({ type: "keyup", key: "l", ctrlKey: true }), "Linux"));
331
+ });
332
});
333
334
describe("terminalNavigationShortcutData", () => {
@@ -371,6 +375,15 @@ describe("terminalNavigationShortcutData", () => {
375
assert.isNull(terminalNavigationShortcutData(event({ key: "ArrowLeft", metaKey: true }), "Linux"));
376
assert.isNull(terminalNavigationShortcutData(event({ key: "a", altKey: true }), "MacIntel"));
377
});
378
+
379
+ it("ignores non-keydown events", () => {
380
+ assert.isNull(
381
+ terminalNavigationShortcutData(
382
+ event({ type: "keyup", key: "ArrowLeft", altKey: true }),
383
+ "MacIntel",
384
+ ),
385
+ );
386
+ });
387
});
388
389
describe("plus key parsing", () => {
apps/web/src/keybindings.ts
+9
@@ -7,6 +7,7 @@ import {
7
import { isMacPlatform } from "./lib/utils";
8
9
export interface ShortcutEventLike {
10
+ type?: string;
11
key: string;
12
metaKey: boolean;
13
ctrlKey: boolean;
@@ -209,6 +210,10 @@ export function isTerminalClearShortcut(
210
event: ShortcutEventLike,
211
platform = navigator.platform,
212
): boolean {
213
+ if (event.type !== undefined && event.type !== "keydown") {
214
+ return false;
215
+ }
216
+
217
const key = event.key.toLowerCase();
218
219
if (key === "l" && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
@@ -229,6 +234,10 @@ export function terminalNavigationShortcutData(
234
event: ShortcutEventLike,
235
platform = navigator.platform,
236
): string | null {
237
+ if (event.type !== undefined && event.type !== "keydown") {
238
+ return null;
239
+ }
240
+
241
if (event.shiftKey) return null;
242
243
const key = normalizeEventKey(event.key);