Logkeys – a utility that records keystrokes in a file.
Install Logkeys on Ubuntu:
sudo apt-get install logkeys
Launch Example:
sudo logkeys --start --output /home/user/logkeys.log --keymap=/home/user/de.map
Stop:
sudo logkeys -k
-s launch
-o path to the file to which information will be written
-k killing process
–us-keymap use english layout
–no-func-keys do not write function keys
Link to files with different key layouts:
http://code.google.com/p/logkeys/wiki/Keymaps#Download