Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix: support modifier-only hotkeys on Windows via native keyboard hook (#226)
Gabriel Stein81db129c6bb4
diff --git a/main.js b/main.jsindex a360f0694..1c0069a5d 100644--- a/main.js+++ b/main.js@@ -644,11 +644,12 @@ async function startApp() {// Right-side single modifiers need the native listener even in tap modeconst isRightSideMod = (hotkey) => /^Right(Control|Ctrl|Alt|Option|Shift|Super|Win|Meta|Command|Cmd)$/i.test(hotkey);- // Whether native listener is needed (push mode always, tap mode only for right-side modifiers)+ const { isModifierOnlyHotkey } = require("./src/helpers/hotkeyManager");+const needsNativeListener = (hotkey, mode) => {if (!isValidHotkey(hotkey)) return false;if (mode === "push") return true;- return isRightSideMod(hotkey);+ return isRightSideMod(hotkey) || isModifierOnlyHotkey(hotkey);};windowsKeyManager.on("key-down", async (key) => {@@ -670,7 +671,6 @@ async function startApp() {}}, WIN_MIN_HOLD_DURATION_MS);} else if (activationMode === "tap") {- // Tap mode with native listener (right-side modifiers)windowManager.showDictationPanel();windowManager.mainWindow.webContents.send("toggle-dictation");}diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.jsindex 60f738ceb..839a47ca8 100644--- a/src/helpers/hotkeyManager.js+++ b/src/helpers/hotkeyManager.js@@ -13,6 +13,18 @@ function isRightSideModifier(hotkey) {return RIGHT_SIDE_MODIFIER_PATTERN.test(hotkey);}+// Modifier-only combos (e.g. "Control+Super") bypass globalShortcut on Windows+// and use the native low-level keyboard hook instead.+const MODIFIER_NAMES = new Set([+ "control", "ctrl", "alt", "option", "shift", "super",+ "meta", "win", "command", "cmd", "commandorcontrol", "cmdorctrl",+]);++function isModifierOnlyHotkey(hotkey) {+ if (!hotkey || !hotkey.includes("+")) return false;+ return hotkey.split("+").every((part) => MODIFIER_NAMES.has(part.toLowerCase()));+}+// Suggested alternative hotkeys when registration failsconst SUGGESTED_HOTKEYS = {single: ["F8", "F9", "F10", "Pause", "ScrollLock"],@@ -97,6 +109,7 @@ class HotkeyManager {hotkey === this.currentHotkey &&hotkey !== "GLOBE" &&!isRightSideModifier(hotkey) &&+ !isModifierOnlyHotkey(hotkey) &&globalShortcut.isRegistered(checkAccelerator)) {debugLogger.log(@@ -105,11 +118,12 @@ class HotkeyManager {return { success: true, hotkey };}- // Unregister the previous hotkey (skip GLOBE and right-side modifiers - they use native listeners)+ // Unregister the previous hotkey (skip native-listener-only hotkeys)if (this.currentHotkey &&this.currentHotkey !== "GLOBE" &&- !isRightSideModifier(this.currentHotkey)+ !isRightSideModifier(this.currentHotkey) &&+ !isModifierOnlyHotkey(this.currentHotkey)) {const prevAccelerator = this.currentHotkey.startsWith("Fn+")? this.currentHotkey.slice(3)@@ -147,6 +161,15 @@ class HotkeyManager {return { success: true, hotkey };}+ // Modifier-only combos use the native keyboard hook on Windows+ if (isModifierOnlyHotkey(hotkey) && process.platform === "win32") {+ this.currentHotkey = hotkey;+ debugLogger.log(+ `[HotkeyManager] Modifier-only "${hotkey}" set - using Windows native listener`+ );+ return { success: true, hotkey };+ }+// Fn+ prefix is a UI-level distinction (user holds Fn to get real F-keys on macOS).// At the OS/Electron level, the accelerator is just the key without Fn.const accelerator = hotkey.startsWith("Fn+") ? hotkey.slice(3) : hotkey;@@ -479,3 +502,4 @@ class HotkeyManager {}module.exports = HotkeyManager;+module.exports.isModifierOnlyHotkey = isModifierOnlyHotkey;diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 04f22d672..85a37c932 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -450,10 +450,14 @@ class IPCHandlers {// When exiting capture mode with a new hotkey, use that to avoid reading stale stateconst effectiveHotkey = !enabled && newHotkey ? newHotkey : hotkeyManager.getCurrentHotkey();+ const { isModifierOnlyHotkey } = require("./hotkeyManager");+ const usesNativeListener = (hotkey) =>+ !hotkey || hotkey === "GLOBE" || isModifierOnlyHotkey(hotkey);+if (enabled) {// Entering capture mode - unregister globalShortcut so it doesn't consume key eventsconst currentHotkey = hotkeyManager.getCurrentHotkey();- if (currentHotkey && currentHotkey !== "GLOBE") {+ if (currentHotkey && !usesNativeListener(currentHotkey)) {debugLogger.log(`[IPC] Unregistering globalShortcut "${currentHotkey}" for hotkey capture mode`);@@ -476,7 +480,7 @@ class IPCHandlers {}} else {// Exiting capture mode - re-register globalShortcut if not already registered- if (effectiveHotkey && effectiveHotkey !== "GLOBE") {+ if (effectiveHotkey && !usesNativeListener(effectiveHotkey)) {const { globalShortcut } = require("electron");if (!globalShortcut.isRegistered(effectiveHotkey)) {debugLogger.log(@@ -487,13 +491,16 @@ class IPCHandlers {}}- // On Windows, restart the listener if in push modeif (process.platform === "win32" && this.windowsKeyManager) {const activationMode = await this.windowManager.getActivationMode();debugLogger.log(`[IPC] Exiting hotkey capture mode, activationMode="${activationMode}", hotkey="${effectiveHotkey}"`);- if (activationMode === "push" && effectiveHotkey && effectiveHotkey !== "GLOBE") {+ const needsListener =+ effectiveHotkey &&+ effectiveHotkey !== "GLOBE" &&+ (activationMode === "push" || isModifierOnlyHotkey(effectiveHotkey));+ if (needsListener) {debugLogger.log(`[IPC] Restarting Windows key listener for hotkey: ${effectiveHotkey}`);this.windowsKeyManager.start(effectiveHotkey);}