I'm trying to analyze my keystrokes over the next month and would like to throw together a simple program to do so. I don't want to exactly log the commands but simply generate general statistics on my key presses.
I am the most comfortable coding this in python, but am open to other suggestions. Is this possible, and if so what python modules should I look at? Has this already been done?
I'm on OSX but would also be interested in doing this on an Ubuntu box and Windows XP.
Here, we are using three methods to detect keypress in Python read_key() , is_pressed() and on_press_key() . The read_key() will read which key a user has pressed on the keyboard, and if it's that key which you wanted, in this case, p , it will print the message You pressed p .
It looks like you need http://patorjk.com/keyboard-layout-analyzer/
This handy program will analyze a block of text and tell you how far your fingers had to travel to type it, then recommend your optimal layout.
To answer your original question, on Linux you can read from /dev/event* for local keyboard, mouse and joystick events. I believe you could for example simply cat /dev/event0 > keylogger
. The events are instances of struct input_event
. See also http://www.linuxjournal.com/article/6429.
Python's struct module is a convenient way to parse binary data.
For OSX, take a look at the source code to logkext. http://code.google.com/p/logkext/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With