diff --git a/desktop/electron.js b/desktop/electron.js index 5e10f57b7..a526fa466 100644 --- a/desktop/electron.js +++ b/desktop/electron.js @@ -6,6 +6,7 @@ const url = require('url'); const fs = require('fs'); const os = require('os'); const userAgent = 'MoodleMobile'; +const isMac = os.platform().indexOf('darwin') != -1; // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -69,10 +70,10 @@ function createWindow() { // Append some text to the user agent. mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + ' ' + userAgent); - // Add shortcut to open dev tools: Control/Cmd + Alt + I. + // Add shortcut to open dev tools: Cmd + Option + I in MacOS, Ctrl + Shift + I in Windows/Linux. mainWindow.webContents.on('before-input-event', function(e, input) { - // The "meta" key is Cmd in MacOS and Control in Windows/Linux. - if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' && input.alt && input.meta) { + if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' && + ((isMac && input.alt && input.meta) || (!isMac && input.shift && input.control))) { mainWindow.webContents.toggleDevTools(); } }, true) @@ -83,7 +84,7 @@ function createWindow() { // See https://github.com/electron/electron/issues/15958 var gotTheLock = app.requestSingleInstanceLock(); -if (!gotTheLock && os.platform().indexOf('darwin') == -1) { +if (!gotTheLock && !isMac) { // It's not the main instance of the app, kill it. app.exit(); return;