Feature Request: Expose `Shortcut.isTakenBySystem` and `Shortcut.isDisallowed`

#237 · closed · 1 comments

View on GitHub ↗

tqtifnypmb

#### Problem `KeyboardShortcuts.Recorder` internally prevents users from recording shortcuts that are either: * **disallowed** (for example `⌘Q`) * **already reserved by the system** However, when developers implement a **custom recorder UI**, there is currently no public API to perform the same validation. This makes it difficult to build custom recorders that behave consistently with `KeyboardShortcuts.Recorder`.

Comments

sindresorhus

I have exposed `Shortcut.isTakenBySystem` (will be in the next version), so you can match the system-conflict check in a custom recorder. I decided not to expose `isDisallowed` though. It is not the general "is this shortcut forbidden" check the name implies. It only guards against a specific bug where Option-only and Option+Shift shortcuts silently do not work in sandboxed apps on macOS 15.0 and 15.1. On macOS 15.2 and later it always returns `false`, so it would be a no-op for nearly everyone, and it is slated for removal once the deployment target moves past 15.1. Exposing a property that does nothing on current systems and is destined to be deleted would just be misleading.