home *** CD-ROM | disk | FTP | other *** search
- Program ShowToggles;
-
- {
- This short program clears the screen and shows the current
- state of the keyboard status byte. It also shows which
- toggles are currently activated.
-
- It is written to be compiled using Turbo Pascal 5.0.
-
- I originally wrote this program due to a faulty keyboard.
- The keyboard would randomly switch on what appeared to be
- the caps lock. Everything that was typed was in upper case,
- the function keys no longer worked, and the numeric keypad
- (101 keyboard) became a cursor pad. Until I wrote this
- program and discovered what the problem was I always ended
- up cold booting the computer to continue with whatever I
- was working on. After the program was written, the
- malfunction occured again and I discovered by running the
- program that the left shift key was logically (not physically)
- on. To correct this problem all I had to do was press it
- and when the key was released the status bit was reset to 0
- and everything was back to normal.
- }
-
- Uses DOS, Crt;
-
- Var
- Regs : Registers;
- Ins,
- CapsLock,
- NumLock,
- ScrollLock,
- Alt,
- Ctrl,
- LeftShift,
- RightShift : Boolean;
-
- Begin
- Clrscr;
- Regs.AH := 2;
- Intr($16,Regs);
- RightShift := (Regs.AL And $1) > 0;
- LeftShift := (Regs.AL And $2) > 0;
- Ctrl := (Regs.AL And $4) > 0;
- Alt := (Regs.AL And $8) > 0;
- ScrollLock := (Regs.AL And $10) > 0;
- NumLock := (Regs.AL And $20) > 0;
- Capslock := (Regs.AL And $40) > 0;
- Ins := (Regs.AL And $80) > 0;
- Writeln;
- Writeln('Status Byte = ',Regs.AL);
- Writeln;
- Writeln('RightShift = ',RightShift);
- Writeln('LeftShift = ',LeftShift);
- Writeln('Ctrl = ',Ctrl);
- Writeln('Alt = ',Alt);
- Writeln('ScrollLock = ',ScrollLock);
- Writeln('NumLock = ',NumLock);
- Writeln('CapsLock = ',CapsLock);
- Writeln('Ins = ',Ins);
- Writeln;
- Writeln;
- End. {ShiftToggle}