From 5071e10dfde69b1fa0777de4d4cc2d6bb4f86c3c Mon Sep 17 00:00:00 2001 From: Jonah <47046556+jwbonner@users.noreply.github.com> Date: Sat, 11 Jan 2025 00:02:46 -0500 Subject: [PATCH] Switch between `metaKey` and `ctrlKey` by platform (closes #307) --- src/hub/SelectionImpl.ts | 6 +++++- src/hub/controllers/VideoController.ts | 8 +++++++- src/shared/renderers/ConsoleRenderer.ts | 2 +- src/shared/renderers/ThreeDimensionRendererImpl.ts | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/hub/SelectionImpl.ts b/src/hub/SelectionImpl.ts index 812b2e8b..2929392a 100644 --- a/src/hub/SelectionImpl.ts +++ b/src/hub/SelectionImpl.ts @@ -61,7 +61,11 @@ export default class SelectionImpl implements Selection { case "ArrowLeft": case "ArrowRight": // Unlocked video uses arrow keys to navigate by frame - if (window.tabs.isUnlockedVideoSelected() || this.mode !== SelectionMode.Static || event.metaKey) { + if ( + window.tabs.isUnlockedVideoSelected() || + this.mode !== SelectionMode.Static || + (window.platform === "darwin" ? event.metaKey : event.ctrlKey) + ) { return; } diff --git a/src/hub/controllers/VideoController.ts b/src/hub/controllers/VideoController.ts index 82b24689..629fc009 100644 --- a/src/hub/controllers/VideoController.ts +++ b/src/hub/controllers/VideoController.ts @@ -171,7 +171,13 @@ export default class VideoController implements TabController { this.SKIP_BACK_BUTTON.addEventListener("click", () => skipTime(-5)); this.SKIP_FORWARD_BUTTON.addEventListener("click", () => skipTime(5)); window.addEventListener("keydown", (event) => { - if (root === null || root.hidden || event.target !== document.body || event.metaKey) return; + if ( + root === null || + root.hidden || + event.target !== document.body || + (window.platform === "darwin" ? event.metaKey : event.ctrlKey) + ) + return; switch (event.code) { case "ArrowUp": case "ArrowDown": diff --git a/src/shared/renderers/ConsoleRenderer.ts b/src/shared/renderers/ConsoleRenderer.ts index b3cfbf80..cf24de16 100644 --- a/src/shared/renderers/ConsoleRenderer.ts +++ b/src/shared/renderers/ConsoleRenderer.ts @@ -108,7 +108,7 @@ export default class ConsoleRenderer implements TabRenderer { // Select filter window.addEventListener("keydown", (event) => { if (root === null || root.hidden || event.target !== document.body) return; - if (event.metaKey && event.key === "f") { + if ((window.platform === "darwin" ? event.metaKey : event.ctrlKey) && event.key === "f") { this.FILTER_INPUT.select(); } }); diff --git a/src/shared/renderers/ThreeDimensionRendererImpl.ts b/src/shared/renderers/ThreeDimensionRendererImpl.ts index 612e9e89..2588f056 100644 --- a/src/shared/renderers/ThreeDimensionRendererImpl.ts +++ b/src/shared/renderers/ThreeDimensionRendererImpl.ts @@ -254,7 +254,7 @@ export default class ThreeDimensionRendererImpl implements TabRenderer { // Create key bindings window.addEventListener("keydown", (event) => { - if (event.metaKey) return; + if (window.platform === "darwin" ? event.metaKey : event.ctrlKey) return; if (event.target !== document.body) return; if (canvasContainer.clientHeight === 0) return; this.keysPressed.add(event.code);