Fix display issues for shortcuts in macos for certain keybinds (closes https://github.com/zen-browser/desktop/issues/2189)

This commit is contained in:
mr. M
2024-10-18 23:27:14 +02:00
parent ffc584e5e6
commit 2cca7a8308

View File

@@ -892,6 +892,14 @@ var gZenCKSSettings = {
this._currentActionID = null;
},
getShortcutFromEvent(event) {
const code = event.code;
if (code.startsWith('Key')) {
return code.replace('Key', '');
}
return event.key;
},
//TODO Check for duplicates
async _handleKeyDown(event) {
if (!this._currentActionID || document.hidden) {
@@ -908,7 +916,7 @@ var gZenCKSSettings = {
// 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;
let shortcut = zenKeycodeFixes[event.code] ?? this.getShortcutFromEvent(event);
shortcut = shortcut.replace(/Ctrl|Control|Shift|Alt|Option|Cmd|Meta/, ''); // Remove all modifiers