Skip to content

Record shortcuts in macOS, like Alfred.app.

License

Notifications You must be signed in to change notification settings

Clipy/KeyHolder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6b3f7d5 · Nov 6, 2024

History

99 Commits
Mar 31, 2024
Oct 13, 2023
Oct 13, 2023
Apr 30, 2020
Oct 13, 2023
Jun 18, 2016
Aug 27, 2019
Apr 30, 2020
Apr 30, 2020
Jun 18, 2016
Oct 13, 2023
Oct 13, 2023
Apr 30, 2020
Nov 6, 2024
Oct 13, 2023
Aug 27, 2019
Oct 13, 2023
Aug 17, 2020

Repository files navigation

KeyHolder

CI Release version License: MIT Carthage compatible Version Platform SPM supported

Record shortcuts in macOS, like Alfred App.

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

  1. Move to the project root directory
  2. Install dependency library with carthage or git submodule
  3. carthage checkout --use-submodules or git submodule update --init --recursive
  4. Open KeyHolder.xcworkspace on Xcode.
  5. build.