How Keyboard Input Traverses from Hardware to Software in Unix-like Systems
When a key is pressed, the keyboard controller generates an interrupt that pauses the CPU, invokes the interrupt handler and driver to translate the scan code into a character, writes it to a device file, which the X server reads and forwards via IPC to the focused window.