Learn something new every day
More Info... by email
Very few people recognize how many calculations, codes and processes are used just to get a character from a computer keyboard onto the screen. One part of this function is the scancode, or a hexadecimal code that is the equivalent of the key pressed on the keyboard. There is a scancode for every key on the keyboard, and there is another separate scancode for when the key is released. Keyboards for different character structures, such as Asian languages, will have a different number of scancodes because the number of keys differs. When the button is pushed, the code is placed into a buffer area so the computer can process and then add the character or recognize the key.
The entire keyboard process can be separated into several different steps. When the key is pushed, the scancode enters the keyboard buffer. While in the buffer, an interrupt is utilized to tell the computer that something has been pushed on the keyboard. After understanding that a key was pushed, the computer looks at the buffer, checks the hexadecimal code, then adds the character or its attribute onto the screen.
Both text and control characters have scancodes. Text keys are the more commonly used ones — containing letters, numbers and symbols — but control characters are used often as well. Control characters are the ones that do not make any symbol but affect the document or character processing, such as the "shift" keys or "enter" key.
Every key on the keyboard actually has two different scancodes, one for pressing and one for releasing. When a key is pushed, it gives one scancode, and the second code adds 128 to the hex value. This might seem useless, because it seems rare for someone to hold a key for several seconds, but this is done often with some control characters such as the "shift" keys or "delete" key.
The hexadecimal value for each key differs based on the keyboard. Each company has its own keyboard, and although the configuration might be similar to or even the same as other ones, the scancodes might be different. This usually is to allow the manufacturer to make keyboards with different key configurations or to add new functions to the keyboard, such as a "print" key.
Another factor in determining the hexadecimal value of each key is the language for which it is made. For example, Japanese and English keyboards have a different number of keys because the number of characters used differs. Different English-speaking countries, such as the United States and England, have different keyboards as well; most English keyboards have 102 keys, and most U.S. keyboards have 101.