Closed seletskiy closed 9 years ago
On 19/08/15 14:54, Stanislav Seletskiy wrote:
I want to make it possible for screenkey to act as key logger for /analyzing my productivity/. But it looks like python-xlib is lacking of required sequence_number field in XKeyEvent structure, which is required to detect key repeating. I have decent repeat rate/delay (140/100), so I do not want to pollute history of logged keys.
Do you have any ideas how to achieve that?
I had to ditch python-xlib, since it didn't really allow to use XKB.
If all you need is the sequence number, it's already in there. In keylistener.py:247 the event you (as long as is a KeyPress/KeyRelease) contains ev.xkey.serial.
You could call XkbSetDetectableAutoRepeat so that KeyRelease is never generated until the key is truly removed.
You can also detect a repeat by checking a release followed by a repeat with the same ev.xkey.time, which wouldn't need to call XkbSetDetectableAutoRepeat.
keylistener.py contains a self-test at the bottom when run stand-alone.
I pushed some code to detect key repeat. I think it could be useful (maybe) to show the repeat in a different way.
I tried to change the color of the text to grey for repeats, but I find it distracting. In any case, if you try keylistener, there's a new field "repeated" which you can use.
@wavexx: Wow, thank you! Get ready to accept new PR :smile:
I guess we can close this
I want to make it possible for screenkey to act as key logger for analyzing my productivity. But it looks like python-xlib is lacking of required sequence_number field in XKeyEvent structure, which is required to detect key repeating. I have decent repeat rate/delay (140/100), so I do not want to pollute history of logged keys.
Do you have any ideas how to achieve that?