From 76d9f26a1656b3be0e675dfeaf3b4674a6eb384a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 25 Jun 2021 16:04:12 +0200 Subject: [PATCH] Fix space shortcuts on non-English layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/vector/platform/ElectronPlatform.tsx | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 6d6c5105d1..f2c204aa17 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -575,9 +575,9 @@ export default class ElectronPlatform extends VectorBasePlatform { onKeyDown(ev: KeyboardEvent): boolean { let handled = false; - switch (ev.key) { - case Key.SQUARE_BRACKET_LEFT: - case Key.SQUARE_BRACKET_RIGHT: + switch (ev.code) { + case "BracketLeft": + case "BracketRight": if (isMac && ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey) { this.navigateForwardBack(ev.key === Key.SQUARE_BRACKET_LEFT); handled = true; @@ -592,18 +592,19 @@ export default class ElectronPlatform extends VectorBasePlatform { } break; - case "1": - case "2": - case "3": - case "4": - case "5": - case "6": - case "7": - case "8": - case "9": - case "0": + case "Digit1": + case "Digit2": + case "Digit3": + case "Digit4": + case "Digit5": + case "Digit6": + case "Digit7": + case "Digit8": + case "Digit9": + case "Digit0": if (SettingsStore.getValue("feature_spaces") && isOnlyCtrlOrCmdKeyEvent(ev)) { - this.navigateToSpace(parseInt(ev.key, 10)); + const spaceNumber = ev.code.slice(5); // Cut off the first 5 characters - "Digit" + this.navigateToSpace(parseInt(spaceNumber, 10)); handled = true; } break;