Browse Source

Link Accelerator docs to globalShortcut module

Usage of Accelerators (i.e. `globalShortcut.register`) is now documented in the Accelerator docs themselves.
Will Tange 8 years ago
parent
commit
aeb774730b
1 changed files with 18 additions and 2 deletions
  1. 18 2
      docs/api/accelerator.md

+ 18 - 2
docs/api/accelerator.md

@@ -2,14 +2,30 @@
 
 > Define keyboard shortcuts.
 
-Accelerators can contain multiple modifiers and key codes, combined by
-the `+` character.
+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.
 
 Examples:
 
 * `CommandOrControl+A`
 * `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
 
 On Linux and Windows, the `Command` key does not have any effect so