I'm trying to use this library: soffes/HotKey in an SwiftUI Application for MacOS. The author describes the usage as follows:
let hotKey = HotKey(key: .r, modifiers: [.command, .option])
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