HotKey
HotKey copied to clipboard
Support for SwiftUI
Do you plan to support SwiftUI (or even extend the documentation, how to integrate into SwiftUI)?
Not author, but you can use the code in an init() of a view (or app) directly, just make sure, as was pointed in another issue, to make the hotkey reference a class variable.
Looks like this in the App :
struct MyApp: App {
let hotKey: HotKey
init() {
// Setup hot key for ⌥⌘R
hotKey = HotKey(key: .r, modifiers: [.command, .option])
hotKey.keyDownHandler = {
print("Pressed at \(Date())")
}
}
...
}
I've used .onAppear and it seems to work well