sindresorhus/keyboardshortcuts — explained in plain English
Analysis updated 2026-05-18
Let users set their own global keyboard shortcut for a menu bar utility.
Add a shortcut recorder to a macOS app's settings screen with automatic conflict warnings.
Support in-app-only shortcuts that fire without registering a global hotkey.
Persist a user's chosen shortcut automatically across app restarts.
| sindresorhus/keyboardshortcuts | sindresorhus/defaults | vorssaint/vorssaint-utils | |
|---|---|---|---|
| Stars | 2,630 | 2,465 | 2,265 |
| Language | Swift | Swift | Swift |
| Last pushed | — | — | 2026-07-03 |
| Maintenance | — | — | Active |
| Setup difficulty | easy | easy | easy |
| Complexity | 2/5 | 2/5 | 2/5 |
| Audience | developer | developer | general |
Figures from each repo's GitHub metadata at analysis time.
KeyboardShortcuts is a Swift package for macOS app developers who want to let users set their own global keyboard shortcuts inside the app's settings screen. A global keyboard shortcut is one that works even when the app is not the active window, which is common in menu bar utilities and productivity tools. Without a library like this, adding user-customizable global shortcuts in a macOS app requires writing a fair amount of boilerplate code dealing with low-level system APIs. This package reduces that to a few lines: you give a shortcut a name in code, drop a recorder component into your settings view, and add a listener that runs code when the user presses their chosen shortcut. The recorder component also detects conflicts with existing system shortcuts and warns the user. The package saves each shortcut to UserDefaults automatically, so the user's choice is remembered across app restarts. It supports both SwiftUI and the older Cocoa (AppKit) UI frameworks. You can listen for a key being pressed down or released, or set up repeating events while the key is held. For apps that do not need global shortcuts, the package also supports in-app shortcuts that only work when the app is focused, using the same recorder component with a different configuration. The package is sandboxed and compatible with the Mac App Store. Internally it uses some older Carbon APIs for the global hotkey registration because Apple has not yet provided modern replacements for that specific capability, but the author notes this should not be a concern for app developers using the package. It is distributed as a Swift Package and requires macOS 10.15 or later.
A Swift package that lets macOS apps offer user-customizable global keyboard shortcuts, complete with a settings recorder component.
Mainly Swift. The stack also includes Swift, SwiftUI, AppKit.
Setup difficulty is rated easy, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.