Search code examples
electronwindowfullscreenchromiumdevtools

Preventing a user from exiting full screen mode to window mode in Electron?


I'm working on a desktop app that needs to have all of its windows always in full screen, I don't want the user to be able to exit to window mode. I already searched for it but didn't find anything, any ideas? Also, can I prevent the user from opening DevTools and that sort of stuff (things coming from chromium and electron by default)?


Solution

  • You probably want to use kiosk mode for you main window, and also disable the DevTools.

    Please refer to the new BrowserWindow() documentation:

    options Object (optional)

    kiosk Boolean (optional) - Whether the window is in kiosk mode. Default is false.

    webPreferences Object (optional) - Settings of web page's features.

    devTools Boolean (optional) - Whether to enable DevTools. If it is set to false, can not use BrowserWindow.webContents.openDevTools() to open DevTools. Default is true.

    Adding these settings should work, you may want to give it a try:

    mainWindow = new BrowserWindow
    (
        {
            // [...]
            kiosk: true,
            webPreferences:
            {
                // [...]
                devTools: false
            }
        }
    );