mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
use cross-platform accelerator in globalShorcut documentation
This commit is contained in:
@@ -14,9 +14,9 @@ const app = electron.app;
|
||||
const globalShortcut = electron.globalShortcut;
|
||||
|
||||
app.on('ready', function() {
|
||||
// Register a 'ctrl+x' shortcut listener.
|
||||
var ret = globalShortcut.register('ctrl+x', function() {
|
||||
console.log('ctrl+x is pressed');
|
||||
// Register a 'CommandOrControl+X' shortcut listener.
|
||||
var ret = globalShortcut.register('CommandOrControl+X', function() {
|
||||
console.log('CommandOrControl+X is pressed');
|
||||
});
|
||||
|
||||
if (!ret) {
|
||||
@@ -24,12 +24,12 @@ app.on('ready', function() {
|
||||
}
|
||||
|
||||
// Check whether a shortcut is registered.
|
||||
console.log(globalShortcut.isRegistered('ctrl+x'));
|
||||
console.log(globalShortcut.isRegistered('CommandOrControl+X'));
|
||||
});
|
||||
|
||||
app.on('will-quit', function() {
|
||||
// Unregister a shortcut.
|
||||
globalShortcut.unregister('ctrl+x');
|
||||
globalShortcut.unregister('CommandOrControl+X');
|
||||
|
||||
// Unregister all shortcuts.
|
||||
globalShortcut.unregisterAll();
|
||||
|
||||
Reference in New Issue
Block a user