home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PJ8_3.ZIP / UKEYS.PAS < prev    next >
Pascal/Delphi Source File  |  1990-02-15  |  878b  |  49 lines

  1. (* ukeys.pas -- (c) 1989 by Tom Swan *)
  2.  
  3. unit ukeys;
  4.  
  5. interface
  6.  
  7. uses crt;
  8.  
  9. function getKey : char;
  10. function keyWaiting : Boolean;
  11. procedure pushKey( ch : char );
  12.  
  13. implementation
  14.  
  15. const
  16.  
  17.    NULL = #0;                 { ASCII NULL character }
  18.    pushedChar : char = NULL;  { Saved char from pushKey procedure }
  19.  
  20. { ----- Return next keyboard or pushed character. }
  21.  
  22. function getKey : char;
  23. begin
  24.    if pushedChar <> NULL then
  25.    begin
  26.       getKey := pushedChar;
  27.       pushedChar := NULL;
  28.    end else
  29.       getKey := ReadKey;
  30. end;
  31.  
  32. { ----- Return true if a character is waiting to be read. }
  33.  
  34. function keyWaiting : Boolean;
  35. begin
  36.    keyWaiting := keypressed or ( pushedChar <> NULL );
  37. end; { keyWaiting }
  38.  
  39. { ----- Push a character back "into" the keyboard. }
  40.  
  41. procedure pushKey( ch : char );
  42. begin
  43.    pushedChar := ch;
  44. end;
  45.  
  46. end.
  47.  
  48.  
  49.