From 9b278cdb0e54818cf7f9f7f3decea809f7f4f315 Mon Sep 17 00:00:00 2001 From: wj-xiao Date: Wed, 14 Jan 2026 17:54:18 +0800 Subject: [PATCH] fix: compatible with macOS's command key combinations --- web/src/pages/desktop/keyboard/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/src/pages/desktop/keyboard/index.tsx b/web/src/pages/desktop/keyboard/index.tsx index 3221e59..4184902 100644 --- a/web/src/pages/desktop/keyboard/index.tsx +++ b/web/src/pages/desktop/keyboard/index.tsx @@ -2,6 +2,7 @@ import { useEffect, useRef } from 'react'; import { useAtomValue } from 'jotai'; import { KeyboardReport } from '@/lib/keyboard.ts'; +import { isModifier } from '@/lib/keymap'; import { client, MessageEvent } from '@/lib/websocket.ts'; import { isKeyboardEnableAtom } from '@/jotai/keyboard.ts'; @@ -46,6 +47,17 @@ export const Keyboard = () => { event.stopPropagation(); const code = event.code; + + // Compatible with macOS's command key combinations + if (code === 'MetaLeft' || code === 'MetaRight') { + pressedKeys.current.forEach((pressedCode) => { + if (!isModifier(pressedCode)) { + handleKeyEvent({ type: 'keyup', code: pressedCode }); + pressedKeys.current.delete(pressedCode); + } + }); + } + pressedKeys.current.delete(code); handleKeyEvent({ type: 'keyup', code }); }