Skip to content

Keyboard Shortcut Translation between macOS and Linux/PC not correct #197

@Kentokamoto

Description

@Kentokamoto

Currently, docs translate keyboard shortcuts between macOS and Linux/PC by simply replacing "CTRL" with the "Command" icon.

useEffect(() => {
// OS detection should run only on the client-side
const isMacUser = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
if (isMacUser) {
if (macosShortcut) {
setDisplayShortcut(macosShortcut);
} else {
// Convert common Windows/Linux keys to macOS equivalents
let convertedShortcut = shortcut;
convertedShortcut = convertedShortcut.replace(/Ctrl\s*\+\s*/gi, "⌘ + ");
convertedShortcut = convertedShortcut.replace(/Alt\s*\+\s*/gi, "⌥ + ");
convertedShortcut = convertedShortcut.replace(/Cmd\s*\+\s*/gi, "⌘ + "); // In case Cmd was used in the base shortcut
convertedShortcut = convertedShortcut.replace(
/Option\s*\+\s*/gi,
"⌥ + "
); // In case Option was used
// Replace individual keys if not part of a combo already handled
convertedShortcut = convertedShortcut.replace(/(?<! )Ctrl/gi, "⌘");
convertedShortcut = convertedShortcut.replace(/(?<! )Alt/gi, "⌥");
setDisplayShortcut(convertedShortcut);
}
} else {
// For non-Mac users, display the original shortcut or Windows/Linux specific if ever needed
setDisplayShortcut(shortcut);
}
}, [shortcut, macosShortcut]);

This does not seem to be entirely correct for some keyboard shortcuts on macOS.
For example: The shortcut to toggle Picture-in-Picture is currently defined as

| Toggle Picture-in-Picture | <KeyboardShortcut shortcut="Shift + Ctrl + ]" /> |

Which is rendered as

Image

However, when doing a fresh Zen install, the default keyboard shortcut is set to:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions