mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-06 13:32:49 +08:00
fix(skin): match macOS recovery shortcut by physical key code and forbid toolbar hook attribute
This commit is contained in:
1 parent
881354e283
commit
cfbf488f75
7 files changed
+63
-6
No files matched your search
@@ -133,16 +133,18 @@ export function requestBuiltInSkin(): void {
|
||||
builtInSkinRequests.value += 1;
|
||||
}
|
||||
|
||||
type RecoveryShortcutEvent = Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey" | "shiftKey" | "key">;
|
||||
type RecoveryShortcutEvent = Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey" | "shiftKey" | "key" | "code">;
|
||||
|
||||
/**
|
||||
* The documented recovery shortcut: Ctrl+Alt+Shift+R, or ⌘+⌥+⇧+R on macOS.
|
||||
* The letter is matched case-insensitively, but every modifier is required so
|
||||
* ordinary app shortcuts (Ctrl+R, Alt+R, Ctrl+Shift+R) keep their meaning.
|
||||
* On macOS, Option/Shift turn the letter key into a derived character (US
|
||||
* layout: ®), so `event.key` is not "r". Match the physical `code` as well;
|
||||
* every modifier is still required so ordinary app shortcuts (Ctrl+R, Alt+R,
|
||||
* Ctrl+Shift+R) keep their meaning.
|
||||
*/
|
||||
export function isRecoveryShortcut(event: RecoveryShortcutEvent): boolean {
|
||||
return (event.ctrlKey || event.metaKey)
|
||||
&& event.altKey
|
||||
&& event.shiftKey
|
||||
&& event.key.toLowerCase() === "r";
|
||||
&& (event.key?.toLowerCase() === "r" || event.code === "KeyR");
|
||||
}
|
||||
Reference in new issue
Block a user