Awesome
KeyHolder
Record shortcuts in macOS, like Alfred App.
<img src="https://github.com/Clipy/KeyHolder/blob/master/Screenshots/double_tap_shortcut.png?raw=true" width="300"> <img src="https://github.com/Clipy/KeyHolder/blob/master/Screenshots/normal_shortcut.png?raw=true" width="300">Usage
CocoaPods
pod 'KeyHolder'
Carthage
github "Clipy/KeyHolder"
github "Clipy/Magnet"
github "Clipy/Sauce"
Example
Set default key combo.
let recordView = RecordView(frame: CGRect.zero)
recordView.tintColor = NSColor(red: 0.164, green: 0.517, blue: 0.823, alpha: 1)
let keyCombo = KeyCombo(doubledModifiers: .command)
recordView.keyCombo = keyCombo
Some delegate methods
func recordViewShouldBeginRecording(_ recordView: RecordView) -> Bool
func recordView(_ recordView: RecordView, canRecordShortcut keyCombo: KeyCombo) -> Bool
func recordView(_ recordView: RecordView, didChangeKeyCombo keyCombo: KeyCombo?)
func recordViewDidEndRecording(_ recordView: RecordView)
Or you can use closures.
let recordView = RecordView(frame: CGRect.zero)
recordView.didChange = { keyCombo in
guard let keyCombo = keyCombo else { return } // Clear shortcut
// Changed new shortcut
}
Dependencies
The source code is dependent on hotkey library.
How to Build
- Move to the project root directory
- Install dependency library with
carthage
orgit submodule
carthage checkout --use-submodules
orgit submodule update --init --recursive
- Open
KeyHolder.xcworkspace
on Xcode. - build.