From 781560d6a1e432e3f2dd178af3b4c21194fc1080 Mon Sep 17 00:00:00 2001 From: Gogades Date: Wed, 21 Oct 2026 15:57:37 -0400 Subject: [PATCH] On Apple products, display cmd/opt in the shortcut help --- .../components/workplane/ShortcutsModal.tsx | 30 +++++++++++++++---- apps/web/src/lib/messages.ar.ts | 1 - apps/web/src/lib/messages.cs.ts | 1 - apps/web/src/lib/messages.da.ts | 1 - apps/web/src/lib/messages.de.ts | 1 - apps/web/src/lib/messages.en.ts | 1 - apps/web/src/lib/messages.fr.ts | 1 - apps/web/src/lib/messages.hu.ts | 1 - apps/web/src/lib/messages.it.ts | 1 - apps/web/src/lib/messages.ja.ts | 1 - apps/web/src/lib/messages.nl.ts | 1 - apps/web/src/lib/messages.pl.ts | 1 - apps/web/src/lib/messages.pt-br.ts | 1 - apps/web/src/lib/messages.ru.ts | 1 - apps/web/src/lib/messages.sl.ts | 1 - apps/web/src/lib/messages.tr.ts | 1 - 16 files changed, 24 insertions(+), 21 deletions(-) diff --git a/apps/web/src/components/workplane/ShortcutsModal.tsx b/apps/web/src/components/workplane/ShortcutsModal.tsx index a96d0b20..1bb3872d 100644 --- a/apps/web/src/components/workplane/ShortcutsModal.tsx +++ b/apps/web/src/components/workplane/ShortcutsModal.tsx @@ -185,7 +185,27 @@ function comboKeys(combo: string) { return parts.length > 0 ? parts : [combo]; } -function ShortcutKeys({ combos }: { combos: string[] }) { +/** + * Whether the keyboard is an Apple one - a Mac, or an iPad with a keyboard, + * which reports itself as a Mac. Browsers do not say "Darwin"; the user agent + * says Macintosh. The editor takes Cmd wherever it takes Ctrl, and Option is + * Alt, so the list shows the keys under the names on that keyboard. + */ +function appleKeyboard() { + return typeof navigator !== "undefined" && /Macintosh|Mac OS X|iPhone|iPad|iPod/.test(navigator.userAgent); +} + +const APPLE_KEY_NAMES: Record = { Ctrl: "Cmd", Alt: "Option" }; + +function keyLabel(key: string, apple: boolean) { + if (key === "Click") return t("shortcuts.click"); + if (key === "RightClick") return t("shortcuts.rightClick"); + if (key === "Drag") return t("shortcuts.drag"); + if (key === "Wheel") return t("shortcuts.wheel"); + return apple ? APPLE_KEY_NAMES[key] ?? key : key; +} + +function ShortcutKeys({ combos, apple }: { combos: string[]; apple: boolean }) { return ( <> {combos.map((combo, comboIndex) => ( @@ -195,7 +215,7 @@ function ShortcutKeys({ combos }: { combos: string[] }) { {comboKeys(combo).map((key, keyIndex) => ( {keyIndex > 0 ? : null} - {key === "Click" ? t("shortcuts.click") : key === "RightClick" ? t("shortcuts.rightClick") : key === "Drag" ? t("shortcuts.drag") : key === "Wheel" ? t("shortcuts.wheel") : key} + {keyLabel(key, apple)} ))} @@ -207,6 +227,7 @@ function ShortcutKeys({ combos }: { combos: string[] }) { /** The groups with their rows, the same markup in the window and on the printed sheet. */ function ShortcutGroups({ groups }: { groups: ShortcutGroup[] }) { + const apple = appleKeyboard(); return (
{groups.map((group) => ( @@ -217,7 +238,7 @@ function ShortcutGroups({ groups }: { groups: ShortcutGroup[] }) {
{t(shortcut.label)}
- +
))} @@ -309,9 +330,6 @@ export function ShortcutsModal({ sketchMode, onClose }: { sketchMode: boolean; o

{t("shortcuts.intro")}

-
- {t("shortcuts.footer")} -