Lets explain this in very simple way, Whenever you press any key on your keyboard or laptop your machine generates a simple key code which depends on the keyboard format you are using. That key code tell your operating system that you have pressed a particular key. Now what keylogger does it save your key stroke into a file. Now further processing depends upon type of Keyloggers. Basically there are two types of keyloggers:
1. Physical keylogger
2. Remote Keylogger
The above processing is same for both physical and remote keyloggers. The difference lies in how they use a log file.
It requires physical access to a victim's system, so that hacker can install it manually. He may be your friend, brother, sister or some close one who actually has physical access to your PC or laptop. Now for getting logs also he has to manually access your PC to check logs. But nowadays few good physical keyloggers are there which sends logs on email address. So nowadays we only need one time Physical access and that's just to install Keylogger and configure an email address to send logs.
These keylogger are a bit different as there name suggest they can be installed from remote, means you don't need any physical access. Remote keyloggers during configuration generates a server that we can send to victim and which does not need any installation. Remote keylogger maintains the records into log files and when victim connects to internet it send the logs to hacker's email address or FTP account that he has putted during configuration time to receive logs.
As we all know new keyloggers are always FUD (fully undetectable) so our antivirus doesn't show any warning messages while infection. So the best method to protect yourself from keyloggers is that encrypt your key strokes by using key scramblers. What a keylogger does is that it monitors key strokes, so when we encrypt our key strokes, Hacker will still receive logs but that garbage as our keys are encrypted and hence he doesn't get anything and victim will remain safe from his keylogger.
Let's understand it with example. Suppose you have typed FunWidTricks.Com through keyoard,
What key scrambler will do? It will Encrypt your each key pressed into some garbage code and keylogger will get this as something like @#dR4Tsqe!)%&C%
So friends what scrambler has done is that it has encrypted your keystrokes and saved you from getting prey to hackers. Secure and protect yourself from keyloggers as you cannot avoid them what you can just do is fool them by encrypting your keystrokes.