I am making a small utility that will detect when the numlock key is pressed.
I am currently able to execute a script to control numlock with a tool called Spark, by Shadow Lab: https://www.shadowlab.org/softwares/spark.php
So, I know that it is possible.
In fact, there are applications such as Quicksilver and many others that do this, so it must be possible (despite obvious security concerns).
How can I achieve this?
From googling, I have found suggestions to use NSEvent.addGlobalMonitorForEvents(matching: .keyDown)
as well as Quartz Event Services.
I have tried with NSEvent and it does not seem to capture the keyDown events, and there is not much documentation on the best way to use Quartz Event Services.
To be clear, my application does not have a window and I would like to be able to capture key-down events system-wide.
Can somebody please advice the best way to capture a keypress?
Thanks!