Skip to content
Global Shortcuts for macOS written by Swift.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SpiceKey.xcodeproj
SpiceKey
SpiceKeyDemo
images
.gitignore
LICENSE
README.md
SpiceKey.podspec

README.md

SpiceKey

Global Shortcuts for macOS written by Swift.

Installation

CocoaPods

pod 'SpiceKey'

Carthage

github "Kyome22/SpiceKey"

Demo

Demo App is in this Project.

image

Usage

  • Register a shortcut

Set ⌘ + A shortcut.

let key = Key.a
let modifierFlags = ModifierFlags.cmd
let keyCombo = KeyCombination(key: key, modifierFlags: modifierFlags)
let spiceKey = SpiceKey(keyCombination: keyCombo, keyDownHandler: {
    // process (key down)
}) {
    // process (key up)
}
spiceKey.register()
  • Create a Key and a ModifierFlags from NSEvent.
func example(event: NSEvent) {
    let key = Key(keyCode: event.keyCode)
    let flags = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
    let modifierFlags = ModifierFlags(flags: flags)
}
  • Get a description of the shortcut
let description = modifierFlags.string + key.string
  • Unregister a shortcut
spiceKey.unregister()
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.