Specifications
released, is considered to be caused by switch bounces, and is disregarded. Different keyboards will have varying key switch
sensitivity, and so these debounce times are declared as constants in the firmware to facilitate modification.
Phantom Keys
A phantom fourth key press (D) will be detected in a scan matrix if two keys (A and B) in the same column are pressed,
along with a third key (C) pressed in the same row as A or B (see Figure 19). If this situation is detected, the global variable
phantom_flag is set to 1, indicating that the current key matrix scan could not accurately determine the state of the keys.
The interface-specific portions of the firmware use this flag to generate error condition information to the host.
Figure 2. Phantom Key Situation
Customizing the Key Matrix Lookup Table
The key matrix scanning routine converts the row and column intersection corresponding to a key location, into a unique and
interface-independent 8-bit code, which is forwarded to the USB and PS/2 scan-conversion portions of the firmware. These
codes closely follow the standard enumeration for a 101/104 key keyboard, with some extensions for newer keys such as
Power, Sleep, and Wake. The key matrix routine uses a lookup table in the file matrix.asm, which must be customized for
different matrix layouts. The lookup entries are organized to correspond to the key matrix positions from (row 0, col 0), (row
1, col 0),...(row 7,col 0),(row 0, col 1),( row 1, col 1),....(row 7, col 1),….(row 0, col 15), (row 1, col 15),....(row 7, col 15).
For instance, if your key matrix layout places the “1” key at the intersection of row 0 and column 0, you would edit the
lookup table in the file matrix.asm and place the constant AT101KB_01 (predefined in the file at101.inc to represent the “1”
key) at the first position in the lookup, and so on for all the keys in your matrix.
The addition of an entirely new key to a matrix is more involved. For example, suppose you wanted to add a new function
key, F13, to an existing key matrix. The following steps are necessary:
• Edit the file at101.inc and assign a new enumeration to the new key. Currently, the enumerations 1-132 and 135 are
used, so add the line “ALT101KB_F13KEY EQU 133” to this file.
• Edit the file matrix.asm and add the newly defined mnemonic for the F13 key to the lookup, in the proper position as
defined by the row and column that the new key will occupy in the physical layout of your scan matrix;
• Edit the file usbkey.asm, and at position 133 of the USB usage code lookup table, add the new usage code for your key;
• Edit the file ps2key.asm, and at position 133 of the scan code lookup tables (there are 3 of them), insert the new scan
codes for your key. Note that some scan codes involve the generation of multibyte codes if additional keys are held
down at the time the key is depressed. If your scan codes require additional make/break key codes prepended or
appended to the base code (see scan codes for keys 75 to 90, for instance) you may have to add code to this module as
well to generate these additional key codes.