AT Keyboard Functions

 The keyboard of the AT (and its Intel 8042 microcomputer interface) is
 programmable.  You can set the key-repeat rate and delay and control the
 "lock" key LED display.

 The keyboard controller generates interrupt level 1 (IRQ 1) on each press
 and release of a key.  IRQ 1 is vectored to INT 09H and handled by BIOS.

 Port 60H is for writing data and is maintained for compatibility with
 earlier models.  If the examples using port 64H don't work, try using 60H.

 Port 64H is for writing commands and data and for reading keyboard status.
 Before sending a command to the keyboard, the BIOS tests its status
 (IN AL,64H) and makes sure a key isn't being pressed or the internal
 buffer isn't full, etc.  There's a small risk if you just go ahead and
 send the command:

     mov   al,cmd_code
     out   64H,al

 For a two-part command such as setting the typeamatic rate, it's wise to
 delay a little while between OUTs:

       mov   al,cmd_code
       out   64H,al
       mov   cx,2000H  ;arbitrary
delay: loop  delay
       mov   al,data_value
       out   64H,al

Cmd  Description
▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
0ffH Reset the keyboard and start internal diagnostics
0feH Resend the last transmission
0fdH-0f7H (NOP)
0f6H Set keyboard to defaults and continue scanning
0f5H Set keyboard to defaults and disable keyboard scanning
0f4H Enable keyboard. Kybd sends 'ACK', clears buffer, and starts scanning
──── ───────────────────────────────────────────────────────────────────────
0f3H Set typeamatic rate and delay.  First send 0f3H, then send data byte:
     ╓7┬6┬5┬4┬3┬2┬1┬0╖
     ║0│dlyreptRate║
     ╙╥┴─┴─┴─┴─┴─┴─┴─╜
      ║ ╚╦╝ ╚═══════╩═► bits 0-4 set the repeat rate (see below)
      ║  ╚════════════► bits 5-6 set initial delay before first repeat:
      ║                          00=250ms; 01=500ms; 10=750ms; 11=1000ms
      ╚═══════════════► bit 7 is always 0
                                                    Value Rate    Value Rate
     This chart is a partial guide for the repeat    0  = 30.0    0aH = 10.0
     rate (bits 0-4).  You can interpolate for       1  = 26.7    0dH =  9.2
     values not shown, but let's face it, you're     2  = 24.0    10H =  7.5
     only interested in the fastest rates.           4  = 20.0    14H =  5.0
                                                     8  = 15.0    1fH =  2.0

     The keyboard is initially set to begin repeating after 1/2-second and
     repeat at 10 repeats per second.  This is much too slow.  A data byte
     of 01H sets the delay to 1/4-second with 26 repeats per second.
     See INT 16H 03H (set keyboard rate and delay)
──── ───────────────────────────────────────────────────────────────────────
0f2H-0efH (NOP)
0eeH Echo.  Diagnostics aid.  Simply sends 0eeH right back.
──── ───────────────────────────────────────────────────────────────────────
0edH Turn LED 'lock key' lights on or off. First send 0edH, then send byte:
     ╓7┬6┬5┬4┬3┬2┬1┬0╖
     ║ not used│c│n│s║
     ╙─┴─┴─┴─┴─┴╥┴╥┴╥╜
                ║ ║ ╚═► ScrollLock light 01H=turn on
                ║ ╚═══► NumLock light    02H=turn on
                ╚═════► CapsLock light   04H=turn on

     The bit positions 0-3 correspond to bits 4-6 of the keyboard flags
     variable in the BIOS Data Area.  You should make an effort to keep the
     flags in sync with the lights.  For instance, if you do a big favor for
     the user and set his ten-key pad into NumLock mode (by setting bit 5 of
     0:0417) then be sure to turn on the corresponding LED (e.g., bit 1).
──── ───────────────────────────────────────────────────────────────────────
See Also: INT 16H (BIOS keyboard services)
          Keyboard Flags
          Keyboard Scan Codes
          Cables and Pin Outs
          BIOS Data Area
          I/O Port Map
                                    -♦-