I need to record my own keystroke data for some academic research. I wrote a regular keylogger for Windows, but now I need to write one for a Unix environment, with the constraint that I have only user-level access. Furthermore, I'm only in the terminal, so this problem is more narrow in one sense.
What would be the best way to do this? Is there some easy way to sort of fork my input so that it goes to a special program as well as to Bash?
I'm using Python or Ruby if there's a lot of code involved, or Bash would work.
The system is Red Hat Enterprise Linux 6.3 if it matters.
Update: I should have listed out more detailed requirements:
- Need to record timing somehow (script -t seems to be fine)
- Need to handle special keystrokes (it matters if a Ctrl or a shift was hit in-between keystrokes); so far as possible, every key event should be handled
- Optional: Might also be good to differentiate key down and key up events for more fine-grained data.