KEYCODES
Each key has a keycode associated with it (see accompanying Table). Keycodes are
always 7 bits long. The eighth bit is a "key-up"/"key-down" flag; a 0 (high level) means
that the key was pushed down, and a 1 (low level) means the key was released (the CAPS
LOCK key is different – see below).
For example, here is a diagram of the "B" key being pushed down. The keycode for "B" is
$35=00110101; due to the rotation of the byte, the bits transmitted are 01101010.
___ ___ ___ ___ ___ ___ ___ ___ _______
KCLK \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_______ ______ ______ ____________
KDAT \__________/ \____/ \____/
0 1 1 0 1 0 1 0
In the next example, the "B" key is released. The keycode is still $35, except that bit 7 is
set to indicate "key-up," resulting in a code of $B5 = 10110101. After rotating, the
transmission will be 01101011:
___ ___ ___ ___ ___ ___ ___ ___ _______
KCLK \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_______ ______ ______ ______
KDAT \__________/ \____/ \__________/
0 1 1 0 1 0 1 0
CAPS LOCK KEY
This key is different from all the others in that it generates a keycode only when it is
pushed down, never when it is released. However, the up/down bit is still used. When
pushing the CAPS LOCK key turns on the CAPS LOCK LED, the up/down bit will be 0;
when pushing CAPS LOCK shuts off the LED, the up/down bit will be 1.
- Appendix H 345 -