Skip to content

Commit

Permalink
🏫 Accelerator example is now the globalShortcut example
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrieseberg committed Aug 8, 2018
1 parent 0336a42 commit dfd5afd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ compile_commands.json
.envrc
.cache
yarn-error.log
.DS_Store

# Coverage
coverage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// The globalShortcut module can register/unregister a global keyboard shortcut
// with the operating system so that you can customize the operations for various
// shortcuts.
//
// Note: The shortcut is global; it will work even if the app does not have the
// keyboard focus. You should not use this module until the ready event of the
// app module is emitted. In this example, we're using "Accelerators":
// Accelerators are Strings that can contain multiple modifiers and key codes,
// combined by the + character, and are used to define keyboard shortcuts
// throughout your application.
//
// For more info, see:
// https://electronjs.org/docs/api/accelerator
// https://electronjs.org/docs/api/global-shortcut

const { app, globalShortcut } = require('electron')

Expand All @@ -22,3 +30,11 @@ app.on('ready', () => {
globalShortcut.register('VolumeUp', () => console.log(`Turn it up!`))
globalShortcut.register('VolumeDown', () => console.log(`Turn it down!`))
})

app.on('will-quit', () => {
// Unregister a shortcut.
globalShortcut.unregister('CommandOrControl+Y')

// Unregister all shortcuts.
globalShortcut.unregisterAll()
})

0 comments on commit dfd5afd

Please sign in to comment.