Below is my simple AppDelegate.swift class.
// AppDelegate.swift import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(aNotification: NSNotification) { NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.KeyDownMask, handler: keyDown); } func keyDown(event:NSEvent!) { print("key down is \(event.keyCode)"); } }
Why are events with keys not printed? What am I missing? I tried to search, but I can not understand.
cocoa swift macos
user3813948
source share