You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/KeyboardShortcuts/Name.swift
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,14 @@ extension KeyboardShortcuts {
34
34
/**
35
35
- Parameter name: Name of the shortcut.
36
36
- Parameter initialShortcut: Optional default key combination. Do not set this unless it's essential. Users find it annoying when random apps steal their existing keyboard shortcuts. It's generally better to show a welcome screen on the first app launch that lets the user set the shortcut.
37
+
- Important: The name must not contain a dot (`.`) because it is used as a key path for observation.
It automatically prevents choosing a keyboard shortcut that is already taken by the system or by the app's main menu by showing a user-friendly alert to the user.
26
82
27
-
It takes care of storing the keyboard shortcut in `UserDefaults` for you.
83
+
It takes care of storing the keyboard shortcut in `UserDefaults` for you when initialized with a name. When initialized with a binding, it reads and writes the shortcut through the binding.
84
+
85
+
- Note: When initialized with a binding, the shortcut is not automatically registered as a global hotkey. You are responsible for storing and handling the shortcut yourself.
- Note: Since macOS 15, for sandboxed apps, it's [no longer possible](https://developer.apple.com/forums/thread/763878?answerId=804374022#804374022) to specify the `Option` key without also using `Command` or `Control`.
Creates a keyboard shortcut recorder that reads and writes to a binding.
166
+
167
+
Use this initializer when you want to manage the shortcut storage yourself instead of using the built-in `UserDefaults` storage. The shortcut is not automatically registered as a global hotkey — you are responsible for storing and handling the shortcut yourself.
168
+
169
+
- Parameter shortcut: The keyboard shortcut binding to read and write.
170
+
- Parameter onChange: Callback which will be called when the keyboard shortcut is changed/removed by the user.
Creates a keyboard shortcut recorder that reads and writes to a binding.
228
+
229
+
Use this initializer when you want to manage the shortcut storage yourself instead of using the built-in `UserDefaults` storage. The shortcut is not automatically registered as a global hotkey — you are responsible for storing and handling the shortcut yourself.
230
+
231
+
- Parameter title: The title of the keyboard shortcut recorder, describing its purpose.
232
+
- Parameter shortcut: The keyboard shortcut binding to read and write.
233
+
- Parameter onChange: Callback which will be called when the keyboard shortcut is changed/removed by the user.
Creates a keyboard shortcut recorder that reads and writes to a binding.
245
+
246
+
Use this initializer when you want to manage the shortcut storage yourself instead of using the built-in `UserDefaults` storage. The shortcut is not automatically registered as a global hotkey — you are responsible for storing and handling the shortcut yourself.
247
+
248
+
- Parameter title: The title of the keyboard shortcut recorder, describing its purpose.
249
+
- Parameter shortcut: The keyboard shortcut binding to read and write.
250
+
- Parameter onChange: Callback which will be called when the keyboard shortcut is changed/removed by the user.
Creates a keyboard shortcut recorder that reads and writes to a binding.
283
+
284
+
Use this initializer when you want to manage the shortcut storage yourself instead of using the built-in `UserDefaults` storage. The shortcut is not automatically registered as a global hotkey — you are responsible for storing and handling the shortcut yourself.
285
+
286
+
- Parameter shortcut: The keyboard shortcut binding to read and write.
287
+
- Parameter onChange: Callback which will be called when the keyboard shortcut is changed/removed by the user.
288
+
- Parameter label: A view that describes the purpose of the keyboard shortcut recorder.
0 commit comments