Phil Storrs PC Hardware book

The sequence of events involved with the PC keyboard

  1. The Keyboard Processor scans the Key Matrix over and over again and when a key on the Keyboard is pressed, the Keyboard Processor detects the key-press and determines a Scan Code for that key, from its position in the matrix. At this point, the Scan Codes represent the keys position in the matrix, rather than what is written on top of the key.

  2. The keyboard processor than clocks the Scan Code into the Keyboard Interface on the computers System Board. This is achieved by the Keyboard Processor sending the Scan Code as serial data on a data line, and clock pulses on a clock line. The cable between the Keyboard and the Computers System Board has four wires, Ground, Plus 5 volt, Data and Clock.

  3. When the keyboard interface circuit has received 11 bits of Key Stroke data, (the old XT computer only used 8 bits) it generates a Hardware Interrupt on IRQ 1, to start the Keyboard Service Routine. As mentioned earlier, the keyboard also generates release-codes when that key is released but as these are only used to generate "Typmatic keypresses", we will not need to look at these here.

  4. When the computers processor gets the Hardware Interrupt signal IRQ 1, via an 8259 IRQ Controller Chip, it runs the Interrupt Handling Routine to find out the Interrupt Number that caused the interrupt. The Interrupt controller chip expands the single IRQ input into the processor, out to 15 Interrupt lines, in modern PC hardware.

  5. The Interrupt Handling Roputine then uses the Interrupt Number to find the Vector, from the Interrupt Vector Table, that points to the start of the Service Routine that processes the interrupt. This routine is called the Keyboard Service Routine and the Vector Address found above, is the Start Address of the Keyboard Service Routine.

  6. The processor loads the Start Address of this routine into it's Program Counter and then proceeds to run the Keyboard Service Routine.

  7. The Keyboard Service Routine takes the Scan Code from the Keyboard Interface Circuit on the System Board and clonsults the Status Bytes, stored in memory locations 00417 and 00418 hex. When we press most keys on the keyboard, they could be Upper or Lower case or Alternate characters, the Status Bytes keep a record of the State of the Shift and ALT keys.

  8. The keyboard Service Routine then generates a Two Byte code that it puts in the Keyboard Buffer area in RAM Memory, from 0041E hex to 0043D hex.

  9. The Two Byte codes take two forms:

  10. Some keys change the state of the Status Bytes and these do not produce a character in the Keyboard Buffer, they only change the bits in the Status Bytes.

  11. Other routines within the operating system, or applications, read the Key Stroke Data from the Keyboard Buffer and make use of it.
Important: Do not confuse the operation of the keyboard interface and the Video System. There is no direct link between the two. The Video System reads data from the Video RAM and produces the Video Display from that. The data in the Video RAM is written there by the Operating System or an Application.

Back to the Keyboard chapter Back to the opening index Book three index