How to capture any key in X?

Posted by cz-david on Stack Overflow See other posts from Stack Overflow or by cz-david
Published on 2010-05-30T18:49:50Z Indexed on 2010/05/30 18:52 UTC
Read the original article Hit count: 426

Filed under:
|
|
|
|

Hi, 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, David Polák

© Stack Overflow or respective owner

Related posts about c++

Related posts about linux