diff --git a/.github/CHANGELOG.yaml b/.github/CHANGELOG.yaml index 64cc21f5..a2b7811f 100644 --- a/.github/CHANGELOG.yaml +++ b/.github/CHANGELOG.yaml @@ -9,6 +9,11 @@ releases: + - name: 3.4.1 + changes: + - title: Shortcut keys no longer override other applications shortcuts + categories: [UI] + authors: [alepouna] - name: 3.4.0 changes: - title: Add a button to the error dialog to copy error messages to clipboard diff --git a/src/main/index.ts b/src/main/index.ts index 0b097f5d..fbd8176a 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, Menu, globalShortcut, shell, ipcMain } from 'electron'; +import { app, BrowserWindow, Menu, shell, ipcMain } from 'electron'; import { NsisUpdater } from 'electron-updater'; import * as path from 'path'; import installExtension, { REDUX_DEVTOOLS, REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer'; @@ -134,18 +134,6 @@ function initializeApp() { }); } - globalShortcut.register('CmdOrCtrl+R', () => { - mainWindow.isFocused() && mainWindow.reload(); - }); - - globalShortcut.register('CmdOrCtrl+F5', () => { - mainWindow.isFocused() && mainWindow.reload(); - }); - - globalShortcut.register('CmdOrCtrl+F12', () => { - mainWindow.isFocused() && mainWindow.webContents.toggleDevTools(); - }); - // Auto updater if (process.env.NODE_ENV !== 'development') { let updateOptions; @@ -225,6 +213,23 @@ function initializeApp() { .then((name) => console.log(`Added Extension: ${name}`)) .catch((err) => console.log('An error occurred: ', err)); } + + //Register keybinds + mainWindow.webContents.on('before-input-event', (event, input) => { + // Check if the input event is for window reloading + if ( + input.type === 'keyUp' && + (input.key.toLowerCase() === 'r' || input.key === 'F5') && + (input.control || input.meta) + ) { + mainWindow.isFocused() && mainWindow.reload(); + } + + // Check if the input even is for dev tools + if (input.type === 'keyUp' && input.key === 'F12' && (input.control || input.meta)) { + mainWindow.isFocused() && mainWindow.webContents.toggleDevTools(); + } + }); }); // Quit when all windows are closed, except on macOS. There, it's common