• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

soffes/HotKey: Simple global shortcuts in macOS

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

soffes/HotKey

开源软件地址(OpenSource Url):

https://github.com/soffes/HotKey

开源编程语言(OpenSource Language):

Swift 98.0%

开源软件介绍(OpenSource Introduction):

HotKey

Version Build Status Swift 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.

HotKey, along with Color, were created for use in Contrast, a macOS app for checking designs for accessible color combinations.

Installation

Carthage

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

github "soffes/HotKey"

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.1.2")

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap