I am building an application for which I need to periodically get information about users keyboard. It is going to be user idle detection application. I have a fairly simple solution to periodically check if the mouse has been moved. But I can’t figure any reasonable non root way to detect if the keyboard has been pressed.
I was thinking about registering a hook every timer timeout and on any key press to unregister it. So if there is no key press for a long time then my program will know if the user is idle.
Anyway, I couldn’t find any global hooks for any key, including modifiers. Is there an easy way to do this? Or would someone have a better way to detect keyboard idleness?
Thanks
After a lot of searching I found this:
When I call it every 100-300ms it detects any pressed key anywhere in X.