describe local shortcuts before global
This commit is contained in:
parent
5c64075032
commit
ba4a2d7c30
1 changed files with 15 additions and 15 deletions
|
@ -2,21 +2,6 @@
|
||||||
|
|
||||||
> Configure local and global keyboard shortcuts
|
> Configure local and global keyboard shortcuts
|
||||||
|
|
||||||
## Global Shortcuts
|
|
||||||
|
|
||||||
You can use the [globalShortcut] module to detect keyboard events even when
|
|
||||||
the application does not have keyboard focus.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const {app, globalShortcut} = require('electron')
|
|
||||||
|
|
||||||
app.on('ready', () => {
|
|
||||||
globalShortcut.register('CommandOrControl+X', () => {
|
|
||||||
console.log('CommandOrControl+X is pressed')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Local Shortcuts
|
## Local Shortcuts
|
||||||
|
|
||||||
You can use the [Menu] module to configure keyboard shortcuts that will
|
You can use the [Menu] module to configure keyboard shortcuts that will
|
||||||
|
@ -46,6 +31,21 @@ If you want to configure a local keyboard shortcut to trigger an action that
|
||||||
_does not_ have a corresponding menu item, you can use the
|
_does not_ have a corresponding menu item, you can use the
|
||||||
[electron-localshortcut] npm module.
|
[electron-localshortcut] npm module.
|
||||||
|
|
||||||
|
## Global Shortcuts
|
||||||
|
|
||||||
|
You can use the [globalShortcut] module to detect keyboard events even when
|
||||||
|
the application does not have keyboard focus.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {app, globalShortcut} = require('electron')
|
||||||
|
|
||||||
|
app.on('ready', () => {
|
||||||
|
globalShortcut.register('CommandOrControl+X', () => {
|
||||||
|
console.log('CommandOrControl+X is pressed')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Shortcuts within a BrowserWindow
|
## Shortcuts within a BrowserWindow
|
||||||
|
|
||||||
If you want to handle keyboard shortcuts for a [BrowserWindow], you can use the `keyup` and `keydown` event listeners on the window object inside the renderer process.
|
If you want to handle keyboard shortcuts for a [BrowserWindow], you can use the `keyup` and `keydown` event listeners on the window object inside the renderer process.
|
||||||
|
|
Loading…
Reference in a new issue