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.
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/