diff --git a/src/plugins/webKeybinds.web/index.ts b/src/plugins/webKeybinds.web/index.ts index 98af85d42..9d88f6372 100644 --- a/src/plugins/webKeybinds.web/index.ts +++ b/src/plugins/webKeybinds.web/index.ts @@ -19,6 +19,7 @@ import { definePluginSettings } from "@api/Settings"; import { Devs, IS_MAC } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +import { SettingsRouter } from "@webpack/common"; const settings = definePluginSettings({ @@ -64,6 +65,26 @@ export default definePlugin({ } ], + start() { + document.addEventListener("keydown", this.onKey); + }, + + stop() { + document.removeEventListener("keydown", this.onKey); + }, + + onKey(e: KeyboardEvent) { + const hasCtrl = e.ctrlKey || (e.metaKey && IS_MAC); + + // Cmd+, is a native shortcut on macos (Vesktop/src/main/mainWindow.ts) + const hasNativeShortcut = IS_VESKTOP && IS_MAC; + + if (hasCtrl && e.key === "," && !hasNativeShortcut) { + e.preventDefault(); + SettingsRouter.openUserSettings(); + } + }, + getBlockedKeybinds() { // Zoom shortcuts, allowing these would cause unpredictable zooming behavior on macos const blocked: string[] = ["mod+plus", "mod+minus", "mod+0"];