Here is the general working of a QWERTY or any other keyboard:
When a tap is done on a keyboard a code is stored in the keyboard buffer by the use of a controller known as the keyboard controller. There is a code associated with each and every key on the keyboard which is known as a scan code. So, when a key is tapped a scan code is saved on the keyboard and then it is sent to the CPU (Central Processing Unit) by the use of an interrupt signal. CPU reads the scan code and then the specific function is executed.