From 0def339ad99acc2c4f9dd1c482142e145d29c986 Mon Sep 17 00:00:00 2001 From: Vivacious Box Date: Thu, 30 Oct 2025 03:58:08 +0100 Subject: [PATCH] Fix modifierkey setting for mac (#2327) ## Description: Currently not an issue, but this is a code smell in case we ever decide to have it editable, current implementation will make the default overwrite the custom setting Pointed out by #1804 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: Mr. Box --- src/client/InputHandler.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/client/InputHandler.ts b/src/client/InputHandler.ts index 686ea2e48..25eab9237 100644 --- a/src/client/InputHandler.ts +++ b/src/client/InputHandler.ts @@ -167,6 +167,9 @@ export class InputHandler { console.warn("Invalid keybinds JSON:", e); } + // Mac users might have different keybinds + const isMac = /Mac/.test(navigator.userAgent); + this.keybinds = { toggleView: "Space", centerCamera: "KeyC", @@ -180,7 +183,7 @@ export class InputHandler { attackRatioUp: "KeyY", boatAttack: "KeyB", groundAttack: "KeyG", - modifierKey: "ControlLeft", + modifierKey: isMac ? "MetaLeft" : "ControlLeft", altKey: "AltLeft", buildCity: "Digit1", buildFactory: "Digit2", @@ -195,12 +198,6 @@ export class InputHandler { ...saved, }; - // Mac users might have different keybinds - const isMac = /Mac/.test(navigator.userAgent); - if (isMac) { - this.keybinds.modifierKey = "MetaLeft"; // Use Command key on Mac - } - this.canvas.addEventListener("pointerdown", (e) => this.onPointerDown(e)); window.addEventListener("pointerup", (e) => this.onPointerUp(e)); this.canvas.addEventListener(