Volver al ranking

soffes/HotKey

Swift

Simple global shortcuts in macOS

swiftmacosappkitcarbonkeyboardshortcutcarthage
Crecimiento de estrellas
Estrellas
1.1k
Forks
90
Crecimiento semanal
Issues
32
5001k
jul 2017jul 2020jul 2023jul 2026
README

HotKey

Version Carthage compatible CocoaPods compatible

Simple global shortcuts in macOS. HotKey wraps the Carbon APIs for dealing with global hot keys to make it easy to use in Swift.

Installation

Swift Package Manager

For installation with Swift Package Manager, simply add the following to your Package.swift:

.package(url: "https://github.com/soffes/HotKey", from: "0.2.1")

Carthage

For installation with Carthage, simply add the following to your Cartfile:

github "soffes/HotKey"

CocoaPods

For installation with CocoaPods, simply add the following to your Podfile:

pod 'HotKey'

Usage

Simply initialize a HotKey with a key and modifiers:

// Setup hot key for ⌥⌘R
let hotKey = HotKey(key: .r, modifiers: [.command, .option])

This is a convenice initializer that creates a KeyCombo for you. You can also initialize with a Carbon key code and Carbon modifier flags if you’re feeling old school.

Now you can set the keyDownHandler and get callbacks for when your hot key is pressed:

hotKey.keyDownHandler = {
  print("Pressed at \(Date())")
}

You can also implement hotKey.keyUpHandler if you’d like.

You don’t need to think about when handlers are registered and unregistered. This all happens automatically based on the HotKey object’s lifecycle.

Thanks

HotKey was heavily inspired by PTHotKey.

Repositorios relacionados
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
serhii-londar/open-source-mac-os-apps

🚀 Awesome list of open source applications for macOS. https://t.me/s/opensourcemacosapps

Creative Commons Zero v1.0 Universalmacosmac
49.7k2.6k
iina/iina

The modern video player for macOS.

SwiftGNU General Public License v3.0macosvideo-player
iina.io
45.7k2.9k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
xitu/gold-miner

🥇掘金翻译计划,可能是世界最大最好的英译中技术社区,最懂读者和译者的翻译平台:

androidtranslation
juejin.cn/tag/%E6%8E%98%E9%87%91%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92
34.3k5k
MonitorControl/MonitorControl

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

SwiftMIT Licensemacoskeyboard
monitorcontrol.app
33.8k982
shadowsocks/ShadowsocksX-NG

Next Generation of ShadowsocksX

SwiftGNU General Public License v3.0shadowsocksswift
32.9k7.8k
kodecocodes/swift-algorithm-club

Algorithms and data structures in Swift, with explanations!

SwiftMIT Licenseswiftdata-structures
29.1k5k
jordanbaird/Ice

Powerful menu bar manager for macOS

SwiftGNU General Public License v3.0macosmenubar
icemenubar.app
29k821
airbnb/lottie-ios

An iOS library to natively render After Effects vector animations

SwiftApache License 2.0animationbodymovin
lottie.airbnb.tech
26.8k3.8k