There are various commercial hardware keyloggers from KeeLog (feel free to check their page) but they are releasing their older but still fully functional PS/2 keylogger design as a open source. There is source code for microcontroller too! Check it!

diy_hardware_keylogger

More...