Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: preserve working shortcut when new registration fails
Yauheni Bandziukevich59c9a192696f
diff --git a/electron/globalShortcut.ts b/electron/globalShortcut.tsindex 8e4449268..f1b046a34 100644--- a/electron/globalShortcut.ts+++ b/electron/globalShortcut.ts@@ -39,14 +39,21 @@ function bindingToAccelerator(binding: ShortcutBinding): string {let currentAccelerator: string | null = null;export function registerOpenAppShortcut(binding: ShortcutBinding, onTrigger: () => void): boolean {- if (currentAccelerator) {- globalShortcut.unregister(currentAccelerator);+ const accelerator = bindingToAccelerator(binding);++ // Same shortcut already registered, nothing to do+ if (accelerator === currentAccelerator) {+ return true;}- const accelerator = bindingToAccelerator(binding);+ // Try to register new shortcut first (before unregistering old one)const success = globalShortcut.register(accelerator, onTrigger);if (success) {+ // Only unregister old shortcut after new one succeeds+ if (currentAccelerator) {+ globalShortcut.unregister(currentAccelerator);+ }currentAccelerator = accelerator;console.log(`Global shortcut registered: ${accelerator}`);} else {