How The Keyboard Works

Feb 05, 2025

Leave a message

Program-controlled scanning mode: In this mode, the MCU calls the keyboard scanning subroutine when idle, and repeatedly scans the keyboard until the user enters a command or data. When the CPU executes a key-in command or processes data, it no longer responds to keyboard input until the keyboard is rescanned.

‌Timed scanning mode: Use the timer inside the MCU to scan the keyboard at regular intervals. When the timer overflows, the CPU responds to the interrupt, scans the keyboard and identifies the key function. This method can respond to keyboard input in a timely manner, but the CPU will perform an empty scan, affecting efficiency.

‌Interrupt scanning mode: When a key on the keyboard is closed, an external interrupt request is generated, and the CPU responds to the interrupt service program to scan the keyboard and identify the key number. This method only responds when a key is pressed, which improves the efficiency of the CPU.

‌Advantages and disadvantages of different working modes:

‌Program-controlled scanning mode: The advantage is that it is simple to implement, and the disadvantage is that the CPU still needs to scan continuously when it does not process the key, affecting the execution efficiency of other functions.
‌Timed scanning mode: The advantage is that it can respond to keyboard input in a timely manner, and the disadvantage is that the CPU will perform unnecessary empty scans, affecting efficiency.
‌Interrupt scanning mode‌: The advantage is that it only responds when a key is pressed, which improves the efficiency of the CPU. The disadvantage is that it is relatively complex to implement.
‌Historical background of keyboard‌: Early teletypewriters were the main interactive input and output devices for computers. As the design of monitors matured, teletypewriters were gradually replaced by keyboards and became independent input devices.

Send Inquiry