Latest 1.5
Homepage https://github.com/Kyome22/SpiceKey
License MIT
Platforms osx 10.12, requires ARC
Frameworks Appkit, Carbon
Authors

Global Shortcuts for macOS written in 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, modifierFlags)
let spiceKey = SpiceKey(keyCombo, keyDownHandler: {
    // process (key down)
}) {
    // process (key up)
}
spiceKey.register()

Set long press ⌘ shortcut.

let longPressSpiceKey = SpiceKey(ModifierFlags.ctrl, 1.0, modifierKeylongPressHandler: {
    // process
})
longPressSpiceKey?.register()       

Set press both side of ⌘ shortcut.

let bothSideSpiceKey = SpiceKey(ModifierFlag.control, bothSideModifierKeysPressHandler: {
    // process
})
bothSideSpiceKey?.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()

Latest podspec

{
    "name": "SpiceKey",
    "version": "1.5",
    "summary": "Global Shortcuts for macOS written in Swift.",
    "description": "By using SpiceKey, you can implement an utility app with shortcuts easily.nDemo app can be downloaded from GitHub.",
    "homepage": "https://github.com/Kyome22/SpiceKey",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Takuto Nakamura": "[email protected]"
    },
    "social_media_url": "https://twitter.com/Kyomesuke3",
    "platforms": {
        "osx": "10.12"
    },
    "source": {
        "git": "https://github.com/Kyome22/SpiceKey.git",
        "tag": "1.5"
    },
    "frameworks": [
        "Appkit",
        "Carbon"
    ],
    "source_files": "SpiceKey/**/*.swift",
    "swift_version": "5",
    "requires_arc": true
}

Pin It on Pinterest

Share This