native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
617 B · 27 lines
Swift
12345678910111213141516171819202122232425262728import AppKit
@MainActorfinal class UserCustomShortcutRegistry { static let shared = UserCustomShortcutRegistry()
private var shortcuts: [UserCustomShortcut] = []
private init() {}
func setShortcuts(_ shortcuts: [UserCustomShortcut]) { self.shortcuts = shortcuts.compactMap { shortcut in let normalized = shortcut.normalized() return normalized.isValid ? normalized : nil } }
func matches(event: NSEvent) -> Bool { shortcuts.contains { $0.matches(event: event) } }
#if DEBUG var registeredShortcutsForTesting: [UserCustomShortcut] { shortcuts } #endif}