fix(shortcuts): 🐛 remove special characters on macos (#8719)

This commit is contained in:
Lukas Runge
2025-05-31 20:49:08 +02:00
committed by GitHub
parent 0e3faf45b1
commit 6cdc640977

View File

@@ -1045,10 +1045,13 @@ var gZenCKSSettings = {
const modifiersActive = modifiers.areAnyActive();
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-not-set`);
// This is because on some OSs (windows/macos mostly) the key is not the same as the keycode
// e.g. CTRL+ALT+3 may be displayed as the euro sign
let shortcut = event.key;
// First, try to read the *physical* key via event.code.
// If event.code is like "KeyS", "KeyA", ..., strip off "Key" → "S".
// Otherwise, fall back to event.key (e.g. "F5", "Enter", etc.).
let shortcut;
if (event.code && event.code.startsWith("Key")) shortcut = event.code.slice(3);
else shortcut = event.key;
shortcut = shortcut.replace(/Ctrl|Control|Shift|Alt|Option|Cmd|Meta/, ''); // Remove all modifiers