Can you detect a keylogger when it is placed? Would it be possible to do that via a keyboard removed event, expecting the keyboard is not removed regularly? So that you for example get a pop-up/alert every time your keyboard (wired) is unplugged and the end-user has to approve that he/she checked if there was a keylogger placed.
Just check around if you want to find them. There are couple of hardware keylogger types.
Wireless keyboards are more vulnerable because all keystrokes can be catched from air. You can build a device that listens specific channel to catch keystrokes and decrypts it, this kind of devices can be placed anywhere in range.
Standart wired keyborads are more secure because you can detect them easily. Some keyloggers can be placed inside the keyboard if there is a empty place. You need to open the keyboard and find some kind of circuit looks suspicous. Some others can be placed on the line that goes through from your keyboard to your mainboard. That devices can store keystrokes in their memory or transmit them to another device in range. Also there are hardware keyloggers can be plugged in to extension ports such as PCI. You can easily detect them by checking your mainboard.
Generally, if someone put a hardware keylogger somewhere around, they need to take it to read data. However as I say, you can store keystrokes with a hardware keylogger and build it to send keystrokes to another device. That device can be placed in anywhere and also can be sending every keystrokes received instantly. For example if I put a hardware keylogger inside your keyboard or on cord, I can make it transmit a mini-computer in range (such as Raspberry) and that raspberry can send it to my e-mail with Wi-Fi.