How do keyloggers steal your passwords?
A keylogger is a hidden program, or sometimes a small gadget, that quietly records every key you press, so your passwords get captured letter by letter and sent to an attacker.

Keylogger
A keylogger is a hidden program, or sometimes a small gadget, that quietly records every key you press. NIST (National Institute of Standards and Technology) defines it as a program that records which keys are pressed to obtain passwords or encryption keys. Your passwords end up in its log, typed out letter by letter. Usually it arrives as a phishing attachment, such as a fake invoice inside a ZIP file. Other times someone plugs a small USB (Universal Serial Bus) device in behind the PC (personal computer).
A passkey is the other side of the story. It lets you sign in by unlocking your device with a fingerprint, face or PIN (personal identification number) instead of typing a password. When you sign in that way, there’s no password to type, so a keylogger has nothing to catch at that moment.
What a keylogger actually does
On Windows, a software keylogger asks the system for a copy of every keystroke. It uses a built-in feature called SetWindowsHookEx, the same API (application programming interface) normal software uses. With the hook type WH_KEYBOARD_LL, it watches low-level keyboard input across all apps, not just one. Because it abuses a normal system feature, MITRE ATT&CK (Adversarial Tactics, Techniques, and Common Knowledge) says keylogging can’t be easily stopped with preventive controls. It also calls keylogging the most prevalent kind of input capture.
The keylogger also notes which window is open. So it knows that your email, and the letters typed after it, went into your bank’s login page. Modern keyloggers grab more: your clipboard, screenshots and even saved browser passwords. Then they quietly upload everything by email, a Telegram bot, FTP (File Transfer Protocol) or HTTP (Hypertext Transfer Protocol).
How a passkey protects your sign-in
- You create a passkey. In your Google Account, you go to Security & sign-in, then How you sign in to Google, then Passkeys and security keys, and choose Create a passkey.
- You unlock, not type. You confirm with your fingerprint, face or PIN on your device, so no password goes through the keyboard.
- Skip password when possible. Turning on this setting makes Google offer your passkey first instead of asking you to type your password.
- Nothing to copy. Google says passkeys can’t be shared, copied or written down, so there’s no typed secret for a keylogger to record.
The result: the moment a keylogger waits for, you typing your main password, stops happening on your normal sign-ins. Your password still exists as a fallback, though. If you type it anywhere, a keylogger can still catch it. A passkey also doesn’t stop malware from stealing session cookies or taking screenshots.
A keylogger is not always on your PC
Many people think antivirus on their own PC keeps them safe. But a keylogger can be a USB stick on a shared computer, or JavaScript hidden in a website’s real login page. Your antivirus sees neither. In February 2011, hardware keyloggers that looked like USB sticks were found on public library PCs in Wilmslow and Handforth, Cheshire. In June 2025, attackers injected JavaScript keyloggers into Outlook on the Web sign-in pages on hacked Exchange servers. In both cases, the keylogger sat somewhere the user’s antivirus couldn’t see.
What to do
- Switch your main email to a passkey, and turn on Skip password when possible, so you stop typing that password on normal sign-ins.
- Don’t open unexpected attachments, such as an invoice inside a ZIP file, because phishing attachments are the main way keyloggers arrive.
- On a shared computer, check behind the PC for a USB device you don’t recognize, and avoid typing important passwords there.
- Remember the limit: your password still works as a fallback, so only type it on a device you trust.
Watch it in 60 seconds
