Windows
Reacting to Keyboard Shortcuts
Desktop applications can react to keyboard shortcuts that are triggered by the user. While the ToDesktop Builder UI allows you to use a keyboard shortcut to toggle window visibility, the ToDesktop API opens up a wider range of behaviour.
In this short guide, we'll use the API to replicate the behaviour for toggling window visibility. Install the API in your target project:
With that installed, we'll use the globalShortcut
namespace to listen to the CommandOrControl+Shift+.
shortcut:
Visit Electron's accelerator documentation for a complete list of valid shortcuts.
Inside the body of the function, we'll use the imported nativeWindow
namespace to handle changing window visibility.
And that's essentially it! While this was a simple example, you have access to the entire todesktop
API to experiment with. For a more complex example, visit our tutorial that uses keyboard shortcuts to extract selected text.