This simple keyboard scanner scans each key until it finds one pressed. It then loads the scan code into the pkey register where the host finds it when it does a programmed I/O read.
The host will know to do a read when it gets an interrupt. The interrupt occurs when a key is pressed and is cleared when the host does a read hren.
In practice, one would not scan at the speed of the processor clock. One would scan more slowly to stop the wires in the keyboard generating radio-frequency interference (RFI). Also, one should use extra register on asynchronous input pressed (see crossing clock domains) to avoid metastability. Finally, one would put the keys in a close to square grid, with as many `pressed' column outputs form the array as row wires feeding the array.
And today, typically, one might use a dedicated microcontroller to scan the keyboard rather than design a hardware circuit.
Note, a standard PC keyboard generates an output byte on press and release and implements a short FIFO internally.
35: (C) 2008-15, DJ Greaves, University of Cambridge, Computer Laboratory. |