Merge pull request #4988 from atom/accelerator-docs
use example accelerators that align with best practices
This commit is contained in:
commit
a9ea8b92f0
2 changed files with 7 additions and 7 deletions
|
@ -5,8 +5,8 @@ multiple modifiers and key codes, combined by the `+` character.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
* `Command+A`
|
* `CommandOrControl+A`
|
||||||
* `Ctrl+Shift+Z`
|
* `CommandOrControl+Shift+Z`
|
||||||
|
|
||||||
## Platform notice
|
## Platform notice
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ const app = electron.app;
|
||||||
const globalShortcut = electron.globalShortcut;
|
const globalShortcut = electron.globalShortcut;
|
||||||
|
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
// Register a 'ctrl+x' shortcut listener.
|
// Register a 'CommandOrControl+X' shortcut listener.
|
||||||
var ret = globalShortcut.register('ctrl+x', function() {
|
var ret = globalShortcut.register('CommandOrControl+X', function() {
|
||||||
console.log('ctrl+x is pressed');
|
console.log('CommandOrControl+X is pressed');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
@ -24,12 +24,12 @@ app.on('ready', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether a shortcut is registered.
|
// Check whether a shortcut is registered.
|
||||||
console.log(globalShortcut.isRegistered('ctrl+x'));
|
console.log(globalShortcut.isRegistered('CommandOrControl+X'));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('will-quit', function() {
|
app.on('will-quit', function() {
|
||||||
// Unregister a shortcut.
|
// Unregister a shortcut.
|
||||||
globalShortcut.unregister('ctrl+x');
|
globalShortcut.unregister('CommandOrControl+X');
|
||||||
|
|
||||||
// Unregister all shortcuts.
|
// Unregister all shortcuts.
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregisterAll();
|
||||||
|
|
Loading…
Reference in a new issue