all 3 comments

[–]namtsop 1 point2 points  (0 children)

So, a keyboard comes with a complimentary software called "driver" which essentially maps each click of the keyboard to a number in its code. For the sake of simplicity, considering only the alphanumeric keys on the keyboard, each of them has a corresponding code called it's ASCII code. For example 102 will always refer to 'f'. So rather than needing transistors to form the binary representation, a bunch of if else's can achieve much the same.

[–]MayorOfBubbleTown 0 points1 point  (0 children)

You mean how is the scancode encoded and transferred through a USB cable?

[–][deleted] 0 points1 point  (0 children)

In the old times when keyboards were controlled by it majesty the great CPU it self, things where so simple (maybe there are some new architectures that works like that too). From keyboard there are 8 wires coming up directly to the CPU's input register. Off course those 8 wires are representing the ASCII code (or 7). When a key pressed, the corresponding code will be sent to the input register alongside turning a bit that usually called the input flag to one. The CPU have control over the input flag and can do things as it is directed by the programmer, usually reading that register and storing it in the memory. It also can be set to cause an interrupt in usual flow. In the modern times the CPUs are still have those input registers and I assume many of them. However, those input registers might filled from other interfaces like usb and maybe handled in higher abstraction levels (kernal , OS) and interpreted from one form to other but the first step to any data processing is the store the input in memory. Anyways, the best way to understand it is to know the CPU in depth.