{"repo":"sindresorhus/KeyboardShortcuts","free":true,"listed":false,"github":"https://github.com/sindresorhus/KeyboardShortcuts","clone":"git clone https://github.com/sindresorhus/KeyboardShortcuts.git","description":"⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes","language":"Swift","stars":2698,"topics":["keyboard-shortcuts","hotkey","macos","swift-package","swift-package-manager","carthage","cocoapods","swiftui","swiftui-components"],"license":"MIT","category":"mobile-apps","readme_excerpt":"This package lets you add support for user-customizable global keyboard shortcuts to your macOS app in minutes. It's fully sandboxed and Mac App Store compatible. And it's used in production by Dato, Jiffy, Plash, and Lungo. I'm happy to accept more configurability and features. PRs welcome! What you see here is just what I needed for my own apps. Requirements macOS 10.15+ Version 3.0.1 Install Add https://github.com/sindresorhus/KeyboardShortcuts in the “Swift Package Manager” tab in Xcode. Usage First, register a name for the keyboard shortcut. Constants.swift You can then refer to this strongly-typed name in other places. You will want to make a view where the user can choose a keyboard shortcut. SettingsScreen.swift There's also support for Cocoa instead of SwiftUI. KeyboardShortcuts.Recorder takes care of storing the keyboard shortcut in UserDefaults and also warning the user if the chosen keyboard shortcut is already used by the system or the app's main menu. Add a listener for when the user presses their chosen keyboard shortcut. App.swift You can also listen to key down with .onKeyDown() That's all! ✨ You can find a complete example in the “Example” directory. You can also find a real-world example in my Plash app. Cocoa Using KeyboardShortcuts.RecorderCocoa instead of KeyboardShortcuts.Recorder : Localization This package supports localizations. PRs welcome for more! 1. Fork the repo. 2. Create a directory that has a name that uses an ISO 639-1 language code and opti","default_branch":null,"files":null,"tree":[],"storefront":"/r/sindresorhus","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sindresorhus/KeyboardShortcuts/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}