Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Ignore non-keydown terminal shortcuts

Julius Marmingef864ef189d5d
diff --git a/apps/web/src/keybindings.test.ts b/apps/web/src/keybindings.test.ts
index a3c88dbd9..4ceb1b920 100644
--- a/apps/web/src/keybindings.test.ts
+++ b/apps/web/src/keybindings.test.ts
@@ -325,6 +325,10 @@ describe("isTerminalClearShortcut", () => {
it("matches Cmd+K on macOS", () => {
assert.isTrue(isTerminalClearShortcut(event({ key: "k", metaKey: true }), "MacIntel"));
});
+
+ it("ignores non-keydown events", () => {
+ assert.isFalse(isTerminalClearShortcut(event({ type: "keyup", key: "l", ctrlKey: true }), "Linux"));
+ });
});
describe("terminalNavigationShortcutData", () => {
@@ -371,6 +375,15 @@ describe("terminalNavigationShortcutData", () => {
assert.isNull(terminalNavigationShortcutData(event({ key: "ArrowLeft", metaKey: true }), "Linux"));
assert.isNull(terminalNavigationShortcutData(event({ key: "a", altKey: true }), "MacIntel"));
});
+
+ it("ignores non-keydown events", () => {
+ assert.isNull(
+ terminalNavigationShortcutData(
+ event({ type: "keyup", key: "ArrowLeft", altKey: true }),
+ "MacIntel",
+ ),
+ );
+ });
});
describe("plus key parsing", () => {
diff --git a/apps/web/src/keybindings.ts b/apps/web/src/keybindings.ts
index 8b7fed6e1..4efcd6fee 100644
--- a/apps/web/src/keybindings.ts
+++ b/apps/web/src/keybindings.ts
@@ -7,6 +7,7 @@ import {
import { isMacPlatform } from "./lib/utils";
export interface ShortcutEventLike {
+ type?: string;
key: string;
metaKey: boolean;
ctrlKey: boolean;
@@ -209,6 +210,10 @@ export function isTerminalClearShortcut(
event: ShortcutEventLike,
platform = navigator.platform,
): boolean {
+ if (event.type !== undefined && event.type !== "keydown") {
+ return false;
+ }
+
const key = event.key.toLowerCase();
if (key === "l" && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
@@ -229,6 +234,10 @@ export function terminalNavigationShortcutData(
event: ShortcutEventLike,
platform = navigator.platform,
): string | null {
+ if (event.type !== undefined && event.type !== "keydown") {
+ return null;
+ }
+
if (event.shiftKey) return null;
const key = normalizeEventKey(event.key);