From c428547b0f865908b3d8d307a99273e87084dfae Mon Sep 17 00:00:00 2001 From: Alessandro Gaggia Date: Mon, 2 May 2022 15:12:25 +0200 Subject: [PATCH] chore: added localshortcut to use instead of globalshortcut, so we prevent registering outside leapp --- packages/desktop-app/electron/main.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/desktop-app/electron/main.ts b/packages/desktop-app/electron/main.ts index 3e81622d1..1cfc38d79 100644 --- a/packages/desktop-app/electron/main.ts +++ b/packages/desktop-app/electron/main.ts @@ -1,7 +1,8 @@ import * as path from "path"; import { environment } from "../src/environments/environment"; -const { app, BrowserWindow, globalShortcut, ipcMain, Tray, Menu } = require("electron"); +const { app, BrowserWindow, ipcMain, Tray, Menu } = require("electron"); +const electronLocalshortcut = require('electron-localshortcut'); const { autoUpdater } = require("electron-updater"); const url = require("url"); @@ -139,17 +140,11 @@ const generateMainWindow = () => { }); app.on("browser-window-focus", () => { - globalShortcut.register("CommandOrControl+R", () => { - console.log("CommandOrControl+R is pressed: Shortcut Disabled"); - }); - globalShortcut.register("F5", () => { - console.log("F5 is pressed: Shortcut Disabled"); - }); + electronLocalshortcut.register(win, ['CommandOrControl+R','CommandOrControl+Shift+R', 'F5'], () => {}); }); app.on("browser-window-blur", () => { - globalShortcut.unregister("CommandOrControl+R"); - globalShortcut.unregister("F5"); + electronLocalshortcut.unregisterAll(win); }); remote.enable(win.webContents);