// the find
soffes/HotKey
Simple global shortcuts in macOS
HotKey is a thin Swift wrapper around macOS Carbon global hotkey APIs, giving you a clean object-based interface instead of wrestling with C callbacks and EventHotKeyRef bookkeeping. It's for macOS app developers who need system-wide shortcuts and don't want to write the Carbon boilerplate themselves.
The lifecycle management is the main thing it gets right — holding a reference to HotKey registers the shortcut, releasing it unregisters automatically, no manual cleanup. The API is genuinely minimal: two lines and you're done. Carbon key codes and modifier flags are mapped to a Swift-native Key enum, so you're not hunting for magic integers. SPM support is clean and the package has no external dependencies.
It's built on Carbon RegisterEventHotKey, which Apple has been threatening to deprecate for years and doesn't work well in sandboxed apps — if your app is on the Mac App Store, this is a non-starter without Accessibility entitlements. There's no support for user-configurable shortcuts (recording, persistence, conflict detection), so anything beyond hardcoded shortcuts requires building that yourself. The library is small enough that a senior dev could read the entire implementation in 20 minutes — which also means there isn't much here beyond what you'd write anyway. Tests only cover KeyCombo and modifier flag conversion, not actual hotkey registration.