mainWindow.webContents.send("shortcut-register-result", success); only happens once in the app's lifetime, and in the renderer process, it looks for window.shortcutRegisterSuccess before attempting to listen for the global shortcut:
if (window.onShortcut && window.shortcutRegisterSuccess) {
window.onShortcut(handleShortcut);
} else {
addEventListener("keydown", (event) => {
// Same shortcut as the global shortcut in the electron app (is that gonna be a problem?)
if (!event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && event.key === "F9") {
handleShortcut("toggle-tracking");
}
});
}
If the page is reloaded, it doesn't get shortcutRegisterSuccess and so the shortcut no longer works — not even within the app, with the keydown listener, because it's intercepted globally.
mainWindow.webContents.send("shortcut-register-result", success);
only happens once in the app's lifetime, and in the renderer process, it looks forwindow.shortcutRegisterSuccess
before attempting to listen for the global shortcut:If the page is reloaded, it doesn't get
shortcutRegisterSuccess
and so the shortcut no longer works — not even within the app, with thekeydown
listener, because it's intercepted globally.This is only a problem during development.