[comp.sys.ibm.pc] Locked Keyboard

darrylo@hpsrlc.HP.COM (Darryl Okahata) (06/25/87)

In comp.sys.ibm.pc, ccjoan@ucdavis.UUCP (ccjoan) writes:

> I have a PC-XT clone with a turbo board.  There is a problem
> with the keyboard sporadically locking in the Caps Lock mode.
> The Number Lock key seems to be reversed at the same time, Number
> Lock on allows the arrow keys to work, off allows number entries.
> 
> I have not been able to reverse the setting by using the shift
> key or kick out of the problem with any combination of control,
> alternate, break, escape, etc.  A warm boot is the only solution.
> 
> Any information on how to solve this problem would be
> appreciated.
> 
> Joan Gargano
> Univ. of California, Davis
> ccjoan@ucdavis
> {ucbvax, sdcsvax}!ucdavis!ccjoan
> ----------

     A fellow Aggie!

     I assume you have a keyboard with little LEDs next to the CAPS and NUM
lock keys.  The problem with PCs (not ATs) with LEDs on the keyboard is that
the actual state of the CAPS and NUM lock keys is stored in RAM IN THE PC, NOT
THE KEYBOARD.  It is a simple matter for an ill-mannered program to change a
few bits in a byte somewhere in low memory (at location 0x0040:0x0017) and
reverse the setting of those keys.  At address 0x0040:0x0017, the upper four
bits are as follows:

	Bit		Meaning
	 7 (msb)	Insert state flag (1 = insert on)
	 6		CAPS state flag (1 = CAPS lock on)
	 5		NUM state flag (1 = NUM lock on)
	 4		SCROLL state flag (1 = SCROLL lock on)

The remaining four LSB bits contain the current state of the ALT, CTRL, and
right and left shift keys.  

     For example, let's say that the CAPS lock key is on, and some program
changes the CAPS lock bit.  Now, the PC thinks that CAPS lock is OFF, but the
keyboard has no way of knowing that the CAPS lock bit has changed, so the CAPS
lock light is still on.  The PC/ATs are able to keep the various LEDs
consistent because, when the shift state changes, information is SENT TO the
keyboard telling it to change also.  When PCs and PC/XTs were designed, the
keyboard was designed without shift state LEDs, and so no provision for
changing such nonexistent LEDs was designed in (the end result is that there is
no way to tell the keyboard that the shift state has changed in PCs and
PC/XTs).

     The solution?

     Write a program that resets the various shift state bits (this program is
about a 5-minute G-job).  Then, whenever you have a problem, you press the
shift state keys on the keyboard until the LEDs are all off (or some default
state), and then run the program which resets the bits in memory to agree with
the LED settings on the keyboard.

     -- Darryl Okahata
	hplabs!hpcea!hpsrla!darrylo
	CompuServe: 75206,3074

Disclaimer: the above is the author's personal opinion and is not the
opinion or policy of his employer or of the little green men that
have been following him all day.