From 5e85f1025af97573809d005e0392f96a450b82cc Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Mon, 7 Oct 2024 18:42:17 +0200 Subject: [PATCH] Fix display issues on keyboard shortcuts settings on some keyboard layouts --- .../components/preferences/zen-settings.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/browser/components/preferences/zen-settings.js b/src/browser/components/preferences/zen-settings.js index b7cdeec97..010b297a1 100644 --- a/src/browser/components/preferences/zen-settings.js +++ b/src/browser/components/preferences/zen-settings.js @@ -689,6 +689,19 @@ var zenMissingKeyboardShortcutL10n = { key_redo: 'zen-key-redo', }; +var zenKeycodeFixes = { + 'Digit0': '0', + 'Digit1': '1', + 'Digit2': '2', + 'Digit3': '3', + 'Digit4': '4', + 'Digit5': '5', + 'Digit6': '6', + 'Digit7': '7', + 'Digit8': '8', + 'Digit9': '9', +} + var gZenCKSSettings = { async init() { await this._initializeCKS(); @@ -853,7 +866,9 @@ var gZenCKSSettings = { input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-not-set`); - let shortcut = event.key; + // 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 = zenKeycodeFixes[event.code] ?? event.key; shortcut = shortcut.replace(/Ctrl|Control|Shift|Alt|Option|Cmd|Meta/, ''); // Remove all modifiers