I want app to listen to global hotkey in background even when app is terminated and show window when hotkey is pressed in Swift in macOS.
Here’s my code now.
import HotKey
import SwiftUI
@main
struct SecureleaveApp: App {
var hotKey = HotKey(key: .l, modifiers: [.command], keyDownHandler: {
//Processing when hotkey is pressed
})
var body: some Scene {
WindowGroup {
MainView()
}
}
}
New contributor
inaaaaaaaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.