diff --git a/je_auto_control/osx/listener/osx_keyboard_listener.py b/je_auto_control/osx/listener/osx_keyboard_listener.py new file mode 100644 index 0000000..777cdde --- /dev/null +++ b/je_auto_control/osx/listener/osx_keyboard_listener.py @@ -0,0 +1,17 @@ +from Cocoa import * +import time +from Foundation import * +from PyObjCTools import AppHelper + +class AppDelegate(NSObject): + def applicationDidFinishLaunching_(self, aNotification): + NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, handler) + +def handler(event): + print(event) + print(str(hex(event.keyCode()))) + +app = NSApplication.sharedApplication() +delegate = AppDelegate.alloc().init() +NSApp().setDelegate_(delegate) +AppHelper.runEventLoop() \ No newline at end of file