From b5b7b1638d1cb3093f4a8455f894c667e3eeb0f6 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 24 Jul 2025 09:15:57 -0700 Subject: [PATCH] Use physical key codes for zoom hotkeys --- src-web/hooks/useHotKey.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src-web/hooks/useHotKey.ts b/src-web/hooks/useHotKey.ts index ffcdb4a0..148fc869 100644 --- a/src-web/hooks/useHotKey.ts +++ b/src-web/hooks/useHotKey.ts @@ -26,8 +26,8 @@ export type HotkeyAction = | 'workspace_settings.show'; const hotkeys: Record = { - 'app.zoom_in': ['CmdCtrl+='], - 'app.zoom_out': ['CmdCtrl+-'], + 'app.zoom_in': ['CmdCtrl+Equal'], + 'app.zoom_out': ['CmdCtrl+Minus'], 'app.zoom_reset': ['CmdCtrl+0'], 'command_palette.toggle': ['CmdCtrl+k'], 'environmentEditor.toggle': ['CmdCtrl+Shift+E', 'CmdCtrl+Shift+e'], @@ -67,6 +67,8 @@ const hotkeyLabels: Record = { 'workspace_settings.show': 'Open Workspace Settings', }; +const layoutInsensitiveKeys = ['Equal', 'Minus', 'BracketLeft', 'BracketRight', 'Backquote']; + export const hotkeyActions: HotkeyAction[] = Object.keys(hotkeys) as (keyof typeof hotkeys)[]; interface Options { @@ -106,7 +108,8 @@ export function useHotKey( return; } - currentKeys.current.add(e.key); + const keyToAdd = layoutInsensitiveKeys.includes(e.code) ? e.code : e.key; + currentKeys.current.add(keyToAdd); const currentKeysWithModifiers = new Set(currentKeys.current); if (e.altKey) currentKeysWithModifiers.add('Alt'); @@ -150,7 +153,9 @@ export function useHotKey( if (options.enable === false) { return; } - currentKeys.current.delete(e.key); + + const keyToRemove = layoutInsensitiveKeys.includes(e.code) ? e.code : e.key; + currentKeys.current.delete(keyToRemove); // Clear all keys if no longer holding modifier // HACK: This is to get around the case of DOWN SHIFT -> DOWN : -> UP SHIFT -> UP ;