How the Computer Accepts Input from the Keyboard

Facebook
Whatsapp
Twitter
LinkedIn
You might think the keyboard simply sends the letter of a pressed key to the computer after all, that is what appears to happen. Actually, the process of accepting input from the keyboard is more complex, as shown in Fig. 1.
How Input is received from the keyboard
Fig. 1: How Input is received from the keyboard.
When a computer accepts input from a keyboard, the process involves both hardware and software working together to interpret and process the signals generated by each key press. Here's how it works step by step:

1. Key Press Detection (Hardware Level)

Key Matrix: Inside the keyboard, there is a grid-like circuit called the key matrix. Each key corresponds to a unique position on this grid.
Switch Closing: When you press a key, it physically closes a switch at the corresponding position in the key matrix. This creates an electrical connection.
Signal Generation: The closing of the switch generates a specific electrical signal corresponding to the key pressed.

2. Signal Transmission

Keyboard Controller: The keyboard has its own microcontroller (keyboard controller) that continuously scans the key matrix for changes. When a key press is detected, the controller identifies the key based on its position in the matrix.
Key Code (Scan Code) Generation: The controller converts the position of the pressed key into a "scan code," which is a numerical code that represents the specific key.
keyboard buffer: The keyboard controller places a code into pan of its memory called the keyboard buffer, to indicate which key was pressed.
  • The keyboard buffer can store many keystrokes at one time. This capability is necessary because some time elapses between the pressing of a key and the computer's reading of that key from the keyboard buffer. With the keystrokes stored in a buffer, the program can react to them when it is convenient.
Transmission to the Computer: The scan code is transmitted to the computer via a connection (USB, PS/2, or wireless).

3. Interrupt Handling (Operating System Level)

Interrupt Request (IRQ): Once the computer receives the scan code, the keyboard sends an interrupt request (IRQ) to the processor. This alerts the operating system that a key has been pressed.
Handling the Interrupt: The operating system uses a special software routine called an interrupt handler to process the input. The interrupt handler reads the scan code sent by the keyboard and determines which key was pressed.

4. Conversion to Character

Scan Code Mapping: The scan code received by the operating system is mapped to a specific character or function using a "keymap" or "keyboard layout" table.
Character or Command: If the key corresponds to a character (e.g., "A", "5", etc.), it is converted into that character. If it corresponds to a control key (e.g., "Ctrl", "Alt", etc.), the system processes it as a command.

5. Display or Action

Application Input: The character or command is sent to the application you are using (e.g., a word processor, web browser, etc.). If it's a character, it is displayed on the screen. If it's a command, the corresponding action is performed (e.g., opening a new window, closing a program, etc.).

6. Key Release

Release Signal: When you release the key, the keyboard sends another signal (a "break code") to inform the computer that the key has been released. The system stops registering the input from that key.

Summary

Key Press: The user presses a key.
Key Matrix: The key press closes a circuit in the keyboard's key matrix.
Signal Generation: The keyboard controller generates a scan code for the key press.
Interrupt Request: The scan code is sent to the computer, triggering an interrupt.
Character Mapping: The operating system maps the scan code to a character or command.
Display/Action: The character is displayed, or the command is executed in the active application.
This process is extremely fast and happens almost instantly when you press a key.

Do you want to say or ask something?

Only 250 characters are allowed. Remaining: 250
Please login to enter your comments. Login or Signup .
Be the first to comment here!
Terms and Condition
Copyright © 2011 - 2025 realnfo.com
Privacy Policy