While computers have already become the most basic tools in our lives, their dominance in our lives is increasing day by day. So, how is it understood by these devices that we press a key on our computer every day? How do computers know when we press a key and reflect it as a letter or an action?
The answer to this question is actually changing day by day with the advancement of computer technology. But the basic logic actually stays the same. Let’s explain in detail, step by step, what a computer does when we press a key on the keyboard.
What do computers do when you press a key on the keyboard?
It is not just the computer or a component on the keyboard that we see on the screen the answer to which key we press on the computer keyboard. In fact, in this process, which takes less than a millisecond, each component plays a role, from the motherboard of your computer to the processor and graphics card. The processes that take place from the moment we press the first button are as follows:
We pressed the button with our finger: What happens first?
As soon as you press the ‘A’ key on your keyboard with your finger, there is a movement in the circuit under this key. The mechanism under the key you press comes into contact with the circuit board at the point just below the circuit on the keyboard. As a result of this contact, a current is formed in the keyboard circuit. In other words, the key you press actually functions as a switch in the keyboard circuit.
There is a current, so how does the computer detect this current?
With the resulting electric current, the ‘keyboard controller’ built into keyboards or computers comes into play. This controller is built into special input/output (I/O) parts (especially laptops) found on motherboards in today’s computers or directly in the keyboards themselves. The current that occurs when you press the keyboard is captured by this controller.
The controller creates a ‘scan code’ based on the stream it captures. Each key on your keyboard has a unique scan code. This code, which consists of only 0s and 1s, is sent to your computer as an electrical pulse or signal, via a USB cable, a direct circuit if a laptop is used, or a receiver that you plug into your computer if it is Bluetooth.
Where is this code sent? Of course, to the processor, which is the brain of the computer:
The scan code reaches the processor of our computer. The processor takes this code and interprets it through the operating system it manages. The operating system checks whether a key has been pressed on a keyboard countless times per second. In fact, every time he asks himself, “Is the key pressed?” he asks. When you press a button and send a scan code to your processor, the answer to this question is ‘Yes!’ and proceed to the next steps.
The operating system initiates an ‘event’ after receiving this scancode. In this event, the system converts the scan code consisting of 0s and 1s into Unicode code or ASCII, which is used as a standard in all technological devices today, where a numerical value is assigned to each character. The code no longer consists of 0s and 1s, but a much richer structure.
What the key does now depends on the apps:
The codes you send with the key or keys you press are interpreted by the computer and operations are performed in a predetermined way. For example, if you pressed only one letter, the information that this letter was pressed is sent to the application you are using. The interpretation of this is also up to practice.
For example, Microsoft Word transfers this command as printing the letter ‘a’ when you press the ‘A’ key, while Valorant interprets this key as we want to move our character to the left.
But still nothing is reflected on our screen? Here it will now reflect:
After all these steps, the application interprets the code presented by the operating system within itself, and transforms this interpretation into a code consisting of 0s and 1s. The interpreted code is sent back to the processor. The processor, on the other hand, takes this code as it is and sends it to the external or internal graphics processor. The graphics processor sends this code to the monitor as electrical signals. And we see the equivalent of this electrical signal with the image reflected on our monitor.
Of course, these pixels we see on our monitor actually emerge as a result of a very different process. To summarize this process, it would be a little simpler to go through Microsoft Word again. Our computer, after determining which letter to enter in Word, checks which font it is. These signals then send electrical signals to the monitor that say, “Look, this is how you’re going to show the letter ‘a’.”
Each and every event we have described above is not actually happening through codes, but by electrical signals. The codes were the system we created for these signals that would make the voltage in the electrical signals easier for people to read. The only thing that components in our computers understand and interpret is changes in voltage.