A keylogger is a piece of software or computer hardware which records keystrokes on a computer. Its most common use is in spyware to obtain passwords and credit card details. The government sometimes uses keyloggers to break encryption and to spy on wrong-doers.