Saving files to a local system

In this section, we are going to provide support for saving files to the local filesystem, as well as handling global keyboard shortcuts.

Depending on the platform, you may want to support either Cmd + S for macOS or Ctrl + S for Windows or Linux desktops.

Let's start by switching back to the menu.js file and registering a new global shortcut. The Electron framework is going to handle it regardless of the focused window. It can handle globally registered shortcuts even if no window is present. This is often used when the application provides support for the minimize to tray feature:

  1. Update the menu.js file and import the globalShortcut object from the Electron framework:
 const { globalShortcut } = require('electron'); ...

Get Electron Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.