2020/08/31 - [Web/JavaScript] - [Electron] Getting Started
2020/08/31 - [Web/JavaScript] - [Electron] BrowserWindow
2020/09/01 - [Web/JavaScript] - [Electron] IPC (Inter Process Communication)
2020/09/01 - [Web/JavaScript] - [Electron] Menu
2020/09/01 - [Web/JavaScript] - [Electron] Global Shortcut
2020/09/01 - [Web/JavaScript] - [Electron] Tray
This post is about the global shortcut of Electron.
The global shortcut is handled by the main process.
Open the main.js file.
const globalShortcut = electron.globalShortcut;
app.on("ready", () => {
createWindow();
globalShortcut.register("alt+1", () => {
console.log("Global shortcut works well");
});
});
app.on("will-quit", () => {
globalShortcut.unregisterAll();
});
Define a globalShortcut and register it.
I made a <ALT+1> and it will show a log.
And unregister it when application quitting.
Now, let's run.
If you input the shortcut keys, the log message will show in the terminal.
This is a simple way to make global shortcuts in Electron.
'Web > JavaScript' 카테고리의 다른 글
[JavaScript] Array Destructuring (0) | 2020.09.02 |
---|---|
[Electron] Tray (0) | 2020.09.01 |
[Electron] Menu (0) | 2020.09.01 |
[Electron] IPC (Inter Process Communication) (0) | 2020.09.01 |
[Electron] BrowserWindow (0) | 2020.08.31 |
댓글