Document how to dynamically register keyboard shortcuts

#22
This commit is contained in:
Sindre Sorhus 2020-08-10 12:18:50 +02:00
parent 61841e4dd5
commit 6b702c6f53
1 changed files with 4 additions and 0 deletions

View File

@ -126,6 +126,10 @@ final class PreferencesViewController: NSViewController {
See [`NSMenuItem#setShortcut`](https://sindresorhus.com/KeyboardShortcuts/Extensions/NSMenuItem.html).
#### Dynamic keyboard shortcuts
Your app might need to support keyboard shortcuts for user-defined actions. Normally, you would statically register the keyboard shortcuts upfront in `extension KeyboardShortcuts.Name {}`. However, this is not a requirement. It's only for convenience so that you can use dot-syntax when calling various APIs (for example, `.onKeyDown(.unicornMode) {}`). You can create `KeyboardShortcut.Name`'s dynamically and store them yourself.
## FAQ
#### How is it different from [`MASShortcut`](https://github.com/shpakovski/MASShortcut)?