Better handling space shortcuts

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-06-28 15:17:26 +02:00
parent 76d9f26a16
commit f8da8254ce
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -575,9 +575,9 @@ export default class ElectronPlatform extends VectorBasePlatform {
onKeyDown(ev: KeyboardEvent): boolean { onKeyDown(ev: KeyboardEvent): boolean {
let handled = false; let handled = false;
switch (ev.code) { switch (ev.key) {
case "BracketLeft": case Key.SQUARE_BRACKET_LEFT:
case "BracketRight": case Key.SQUARE_BRACKET_RIGHT:
if (isMac && ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey) { if (isMac && ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey) {
this.navigateForwardBack(ev.key === Key.SQUARE_BRACKET_LEFT); this.navigateForwardBack(ev.key === Key.SQUARE_BRACKET_LEFT);
handled = true; handled = true;
@ -591,24 +591,18 @@ export default class ElectronPlatform extends VectorBasePlatform {
handled = true; handled = true;
} }
break; break;
}
case "Digit1": if (
case "Digit2": !handled &&
case "Digit3": SettingsStore.getValue("feature_spaces") &&
case "Digit4": ev.code.startsWith("Digit") &&
case "Digit5": isOnlyCtrlOrCmdKeyEvent(ev)
case "Digit6": ) {
case "Digit7":
case "Digit8":
case "Digit9":
case "Digit0":
if (SettingsStore.getValue("feature_spaces") && isOnlyCtrlOrCmdKeyEvent(ev)) {
const spaceNumber = ev.code.slice(5); // Cut off the first 5 characters - "Digit" const spaceNumber = ev.code.slice(5); // Cut off the first 5 characters - "Digit"
this.navigateToSpace(parseInt(spaceNumber, 10)); this.navigateToSpace(parseInt(spaceNumber, 10));
handled = true; handled = true;
} }
break;
}
return handled; return handled;
} }