diff --git a/electron_app/package.json b/electron_app/package.json index 08f8de39c59..fff68a7f957 100644 --- a/electron_app/package.json +++ b/electron_app/package.json @@ -12,21 +12,6 @@ "minimist": "^1.2.0", "png-to-ico": "^1.0.2" }, - "iohook": { - "targets": [ - "node-64", - "electron-69" - ], - "platforms": [ - "win32", - "darwin", - "linux" - ], - "arches": [ - "x64", - "ia32" - ] - }, "cmake-js": { "runtime": "electron", "runtimeVersion": "4.0.4" diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index c81f3687291..ed7a600ad83 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -218,6 +218,25 @@ export default class ElectronPlatform extends VectorBasePlatform { ipcRenderer.send('check_updates'); } + startListeningKeys() { + // Tell iohook to start listening for key events + ipcRenderer.send('start-listening-keys'); + } + + stopListeningKeys() { + // Tell iohook to stop listening for key events + ipcRenderer.send('stop-listening-keys'); + } + + onKeypress(self: any, callback: (ev, event) => void ) { + ipcRenderer.on('keypress', callback.bind(self)); + } + + onWindowBlurred(callback: () => void) { + // Callback to run on window blur (window loses focus) + ipcRenderer.on('window-blurred', callback); + } + addGlobalKeybinding(keybindName: string, keybindCode: string, callback: () => void, releaseCallback: () => void) { // Add a keybinding that works even when the app is minimized const keybinding = {name: keybindName, code: keybindCode};