Merge pull request #7750 from bheart/master
Document the fact that Accelerators are used by the globalShortcut module
This commit is contained in:
commit
bb6d15ee10
1 changed files with 18 additions and 2 deletions
|
@ -2,14 +2,30 @@
|
||||||
|
|
||||||
> Define keyboard shortcuts.
|
> Define keyboard shortcuts.
|
||||||
|
|
||||||
Accelerators can contain multiple modifiers and key codes, combined by
|
Accelerators are Strings that can contain multiple modifiers and key codes,
|
||||||
the `+` character.
|
combined by the `+` character, and are used to define keyboard shortcuts
|
||||||
|
throughout your application.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
* `CommandOrControl+A`
|
* `CommandOrControl+A`
|
||||||
* `CommandOrControl+Shift+Z`
|
* `CommandOrControl+Shift+Z`
|
||||||
|
|
||||||
|
Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module
|
||||||
|
using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback)
|
||||||
|
method, i.e.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const {app, globalShortcut} = require('electron')
|
||||||
|
|
||||||
|
app.on('ready', () => {
|
||||||
|
// Register a 'CommandOrControl+Y' shortcut listener.
|
||||||
|
globalShortcut.register('CommandOrControl+Y', () => {
|
||||||
|
// Do stuff when Y and either Command/Control is pressed.
|
||||||
|
})
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Platform notice
|
## Platform notice
|
||||||
|
|
||||||
On Linux and Windows, the `Command` key does not have any effect so
|
On Linux and Windows, the `Command` key does not have any effect so
|
||||||
|
|
Loading…
Add table
Reference in a new issue