kbdevents is a Linux kernel module that allows you to execute a command for every pressed key or to see its keycode. It includes some sample scripts that can be used as the command to be executed on every key pressed: a keylogger, a script to take screenshots in the console by pressing the PrtSc key, and another one that imitates typewriter sounds.
It works for me using Gentoo Linux with sys-kernel/gentoo-sources-2.6.29-r1. Check if you enabled kprobes: # zgrep PROBES /proc/config.gz CONFIG_KPROBES=y CONFIG_KRETPROBES=y CONFIG_HAVE_K...