See Section 5 for a general description of the Keyboard Handler.
The console key code register is read in response to an IRQ interrupt that is generated whenever a key stroke is detected by the hardware. The key code is compared with the prior key code accepted (CH1), if the codes are not identical then the new code is accepted and stored in the key code FIFO (CH) and in the prior key code variable (CH1). If the codes ave identical, then the new code is accepted only if a suitable key debounce delay has transpired since the prior value was accepted.
If the key code read and accepted is the code for [CTRL] 1, then the display start/stop flag (SSFLAG) is complemented and the value is not stored in the key code FIFO (CH).
In addition to the reading of the key data, SRTIMR is set to $30 for all interrupts received (see E8), and ATRACT is set to 0 whenever a new coda is accepted (see B10).
The Keyboard Handler obtains all key data from CH; whenever a code is extracted from that 1-byte FIFO, the Handler stores a value of $FF to the FIFO to indicate that the code has been read. See Section 5 for further discussion of the Keyboard Handler's processing of the key codes.
El CH1* [02F2,1] -- Prior keyboard character code.
CH1 contains the key code value of the key most recently read and accepted.
E2 KEYDEL* [02F1,1] -- Debounce delay timer.
KEYDEL is set to a value of 3 whenever a key code is accepted, and is decremented every 60th of a second by the stage 2 VBLANK process (until it reaches zero).
E3 CH [02FC,1] -- Keyboard character code FIFO.
CH is a 1-byte FIFO that contains either the value of the most recently read and accepted key code or the value $FF (which indicates that the FIFO is empty). The FIFO is normally read by the Keyboard Handler, but can be read by a user program.
Key data can also be stored into CH by the Autorepeat logic as explained in the discussion relating to E8.
The Keyboard Handler allows the direct generation of more than half of the 256 ATASCII codes; but codes $80-9A and codes $A0-FC can be generated only with the "inverse video made" active. The ATARI key acts as an on/off toggle for this mode, and all characters (except for screen editing control characters) will be subject to inversion when the mode is active.
E9 INVFLG [02B6,1] -- Inverse video flag
INVFLG is normally zeroed indicating that normal video ATASCII codes (bit 7 = 0) are to be generated from keystrokes; whenever INVFLG is nonzero, inverse video ATASCII codes (bit 7 = 1) will be generated. The special control codes are exempt from this bit manipulation.
INVFLG is set to zero by power-up and system reset.
The Keyboard Handler inverts bit 7 of INVFLG whenever the ATARI keg is pressed; the lower order bits are not altered and are assumed to be zero.
The Keyboard Handler's "exclusive or's" (XOR's) the ATASCII key data with the value in INVFLG at all times; the normal values of $00 and $80 thus lead to control of the inverse video bit (bit 7).
The console keys are sensed directly from the hardware register CONSOL [D01F]; see the ATARI Home Computer Hardware Manual for details.