soffes / HotKey

Simple global shortcuts in macOS
MIT License
921 stars 82 forks source link

Doesn't seem to work? #26

Closed ospfranco closed 2 years ago

ospfranco commented 4 years ago

Hey, first thanks for creating the library, I was just in the process of setting it up, so I'm just doing some basic test, but this doesn't seem to work:

func applicationDidFinishLaunching(_ aNotification: Notification) {
       // Register global hotkey
        let hotkey = HotKey(keyCombo: KeyCombo(key: .r, modifiers: [.command, .option]))
        hotkey.keyDownHandler = {
            print("Something should happen")
        }

Am I registering it the wrong place or?

ospfranco commented 4 years ago

Ah, I just got it working, the hotkey declaration cannot be a local variable, it needs to be in the class so it doesn't get de-allocated, I think it would be useful to mention it on the Readme, I will create a PR

ospfranco commented 4 years ago

https://github.com/soffes/HotKey/pull/27

wilbertliu commented 4 years ago

Thank you so much @ospfranco, it's truly helpful! 🙏🏻

brendanballon commented 4 years ago

thanks I needed this! needs to be added to readme

lx70770 commented 3 years ago

thanks

LingYanSi commented 1 year ago

thanks