Once I pulled a prank on a colleague by setting up a 555 timer inside their keyboard so that alt+f4 would constantly get pressed (every ~1 second). Because that friend was a software hacker, I knew he would look for rootkits and all sorts of nefarious software issues that could lead to this behavior. Anyhow, he did eventually figure it out (not after he was sure his BIOS was infected - yes this was 2007).
What I learned during that prank was that keyboards are very complicated. A keyboard is essentially a giant switching system where pressing keys closes circuits, and a microprocessor looks to see what lines are high/low and infers which keys have been pressed. There's whole systems designed around avoiding "ghost keys", which arise because the number of combinations of possible simultaneous button presses of the switching system far outnumber the possible combinations of signals.
What I learned during that prank was that keyboards are very complicated. A keyboard is essentially a giant switching system where pressing keys closes circuits, and a microprocessor looks to see what lines are high/low and infers which keys have been pressed. There's whole systems designed around avoiding "ghost keys", which arise because the number of combinations of possible simultaneous button presses of the switching system far outnumber the possible combinations of signals.