soffes/HotKey

Initializing hotkey in viewDidLoad() results in nothing when shortcut is activated

brendanballon opened this issue · 2 comments

Here's my code (I'm just making a test application)

import Cocoa
import HotKey

class ViewController: NSViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let hotkey = HotKey(keyCombo: KeyCombo(key: .p, modifiers: [.control, .command]))
        hotkey.keyDownHandler = {
            print("Something should happen")
        }
        // Do any additional setup after loading the view.
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }

    }

I'm just wondering if I'm doing any of this right, as you may be able to tell I'm a beginner.

@brendanballon hi, got same error, how did you handle it?

same issue here