Chapter 18: Keyboards, Mice, and Pointing Devices^459
status byte (which indicates if theSHIFT,CTRL, orALTkeys are in use) and the
scan code to generate a two-byte key code that is put into the keyboard buffer
in RAM.
- The two bytes of the key code are used separately to indicate the key’s identity.
For a normal character, the first (low) byte is the ASCII (American Standard
Code for Information Interchange) code of the character and the second (high)
byte contains the scan code. A special character is represented with zeroes in
the low byte and the scan or other coding in the high byte. - The ASCII code of the key is passed to the application which completes
its processing.
Make and Break Codes
The keyboard processor is constantly scanning the keyboard grid to detect if any key
being pressed, released, or held down. When one of these actions is detected, the key-
board processor sends a scan code to the PC. Two different types of scan codes are used:
makecodesandbreakcodes.Amakecodeissentwhenakeyispressedorhelddown.A
break code is sent when a key is released. Each key location on the grid (which means
each key) is assigned unique make and break codes, which allow the PC to determine
the action and the key involved by the scan code sent from the keyboard controller.
The PC has no real way of knowing when a key is pressed or released. The make and
break codes indicate when the key was pressed and released, which provides the PC
with the information it needs. This allows the PC to detect repeating keys (a key held
down to repeat it) and how many to generate. Table 18-2 lists a few of the scan codes
used on 101-key and 104-key keyboards.
To type an uppercaseA, the following keystrokes would be entered:
- The RightSHIFTkey is pressed.
- TheAkey is pressed.
- TheAkey is released.
- The RightSHIFTkey is released.
This causes the following actions to be taken by the keyboard controller:
- The make code for the RightSHIFTkey (59) is sent to the keyboard interface.
- The make code for theAkey (1C) is sent to the keyboard interface.
- The break code for theAkey (F0 1C) is sent to the keyboard interface.
- The break code for the RightSHIFTkey (F0 59) is sent to the keyboard interface.