{<<<< KeyStat >>>>}
{ From: COMPLETE TURBO PASCAL by Jeff Duntemann  }
{ Scott, Foresman & Co. 1986  ISBN 0-673-18600-8 }
{ Described in section 20.6 -- Last mod 2/1/86   }
{ This version specific to PC/MS DOS             }

FUNCTION KeyStat(VAR Ch : Char) : Boolean;

TYPE
  RegPack = RECORD
              AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer
            END;

VAR
  Registers : RegPack;

BEGIN
  Registers.AX := $0600;   { DOS call 6: Direct Console I/O }
  Registers.DX := 255;     { Selects non-echo read function }
  MSDOS(Registers);        { Make the DOS call }
  Ch := Chr(Registers.AX); { The character is returned in AX }
  KeyStat := Ch <> Chr(0)
END;
