home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / keyboard / showtogl / showtogl.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1988-12-16  |  1.9 KB  |  63 lines

  1. Program ShowToggles;
  2.  
  3. {
  4.    This short program clears the screen and shows the current
  5.    state of the keyboard status byte.  It also shows which
  6.    toggles are currently activated.
  7.  
  8.    It is written to be compiled using Turbo Pascal 5.0.
  9.  
  10.    I originally wrote this program due to a faulty keyboard.
  11.    The keyboard would randomly switch on what appeared to be
  12.    the caps lock.  Everything that was typed was in upper case,
  13.    the function keys no longer worked, and the numeric keypad
  14.    (101 keyboard) became a cursor pad.  Until I wrote this
  15.    program and discovered what the problem was I always ended
  16.    up cold booting the computer to continue with whatever I
  17.    was working on.  After the program was written, the
  18.    malfunction occured again and I discovered by running the
  19.    program that the left shift key was logically (not physically)
  20.    on.  To correct this problem all I had to do was press it
  21.    and when the key was released the status bit was reset to 0
  22.    and everything was back to normal.
  23. }
  24.  
  25. Uses DOS, Crt;
  26.  
  27. Var
  28.   Regs : Registers;
  29.   Ins,
  30.   CapsLock,
  31.   NumLock,
  32.   ScrollLock,
  33.   Alt,
  34.   Ctrl,
  35.   LeftShift,
  36.   RightShift : Boolean;
  37.  
  38. Begin
  39.   Clrscr;
  40.   Regs.AH := 2;
  41.   Intr($16,Regs);
  42.   RightShift := (Regs.AL And $1) > 0;
  43.   LeftShift  := (Regs.AL And $2) > 0;
  44.   Ctrl       := (Regs.AL And $4) > 0;
  45.   Alt        := (Regs.AL And $8) > 0;
  46.   ScrollLock := (Regs.AL And $10) > 0;
  47.   NumLock    := (Regs.AL And $20) > 0;
  48.   Capslock   := (Regs.AL And $40) > 0;
  49.   Ins        := (Regs.AL And $80) > 0;
  50.   Writeln;
  51.   Writeln('Status Byte = ',Regs.AL);
  52.   Writeln;
  53.   Writeln('RightShift = ',RightShift);
  54.   Writeln('LeftShift  = ',LeftShift);
  55.   Writeln('Ctrl       = ',Ctrl);
  56.   Writeln('Alt        = ',Alt);
  57.   Writeln('ScrollLock = ',ScrollLock);
  58.   Writeln('NumLock    = ',NumLock);
  59.   Writeln('CapsLock   = ',CapsLock);
  60.   Writeln('Ins        = ',Ins);
  61.   Writeln;
  62.   Writeln;
  63. End. {ShiftToggle}