From e1ef02058d719acb23a728b161dced67c564a1af Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 1 Oct 2025 22:27:39 +0300 Subject: [PATCH] fix(client): function keys (e.g. help) not working due to change in modifiers --- apps/client/src/services/shortcuts.spec.ts | 9 +++++++++ apps/client/src/services/shortcuts.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/client/src/services/shortcuts.spec.ts b/apps/client/src/services/shortcuts.spec.ts index d22a1e081..405c71359 100644 --- a/apps/client/src/services/shortcuts.spec.ts +++ b/apps/client/src/services/shortcuts.spec.ts @@ -148,6 +148,15 @@ describe("shortcuts", () => { expect(matchesShortcut(event, "a")).toBe(false); }); + it("should match function keys even with no modifiers", () => { + let event = createKeyboardEvent({ key: "F1", code: "F1" }); + expect(matchesShortcut(event, "F1")).toBeTruthy(); + expect(matchesShortcut(event, "f1")).toBeTruthy(); + + event = createKeyboardEvent({ key: "F1", code: "F1", shiftKey: true }); + expect(matchesShortcut(event, "Shift+F1")).toBeTruthy(); + }); + it("should handle alternative modifier names", () => { const ctrlEvent = createKeyboardEvent({ key: "a", code: "KeyA", ctrlKey: true }); expect(matchesShortcut(ctrlEvent, "control+a")).toBe(true); diff --git a/apps/client/src/services/shortcuts.ts b/apps/client/src/services/shortcuts.ts index 1ba7919b3..92bb02d66 100644 --- a/apps/client/src/services/shortcuts.ts +++ b/apps/client/src/services/shortcuts.ts @@ -163,7 +163,8 @@ export function matchesShortcut(e: KeyboardEvent, shortcut: string): boolean { const expectedMeta = modifiers.includes('meta') || modifiers.includes('cmd') || modifiers.includes('command'); // Refuse key combinations that don't include modifiers because they interfere with the normal usage of the application. - if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta)) { + // Function keys are an exception. + if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta) && !/f\d+/.test(key)) { return false; }