Key logging software runs in the background, in a stealth mode that isn't easy to detect on a PC. It collects every keystroke and hides that information in a file.
There are legitimate uses for this kind of software, to control or audit use of company owned computers, for example. But this kind of software is also used by attackers to collect identification and authentication information, login IDs and passwords. When it's placed on a computer by an attacker, it's often placed there using Trojan software. The keystroke information is collected in files, to be retrieved later, or sometimes the Trojan includes instructions to send them to the attacker.
Sophisticated key loggers do much more than just log keystrokes. They can monitor the applications that are used, the URL's that are visited and much more. And they can do this in ways that are very difficult to detect.