I'm trying to use this library: soffes/HotKey in an SwiftUI Application for MacOS. The author describes the usage as follows:
- Set up Hotkey:
let hotKey = HotKey(key: .r, modifiers: [.command, .option])
- set the keyDownHandler and get callbacks for when your hot key is pressed:
hotKey.keyDownHandler = {
print("Pressed at \(Date())")
}
My problem is that I don't know where I have to put the Handler. Any Ideas?
Okay so I figured it out. The
keyDownHandler
really just defines what should happen when a hotkey is pressed so you can just put it into the.onAppear {}
after your body View