SwiftUI uses a different event handling model than AppKit's responder chain. This NSViewRepresentable approach is afaik the recommended way to access AppKit's event handling capabilities from SwiftUI.
https://developer.apple.com/documentation/swiftui/nsviewrepr...