Board index » delphi » Keyboard Read

Keyboard Read

Does anyone known if there is a Pascal equivelent to the BASIC command INKEY$ ?
This command checks the keyboard buffer for any keystrokes and returns the value
to the module that called it. This command would be useful if one wanted to check
the keyboard and the mouse while in a loop. This way the user does not have to hit enter after typing in a char. Thanks in advance, Rod.

-

                        -Rodrigo Strougo (rstro...@cc.gatech.edu)

 

Re:Keyboard Read


Quote
rstro...@cc.gatech.edu (Rodrigo Strougo) wrote:
>Does anyone known if there is a Pascal equivelent to the BASIC command INKEY$ ?
>This command checks the keyboard buffer for any keystrokes and returns the value
>to the module that called it. This command would be useful if one wanted to check
>the keyboard and the mouse while in a loop. This way the user does not have to hit enter after typing in a char. Thanks in advance, Rod.
>-

Here it is again from Borland's on line help for Turbo v 6.0
<clifp...@airmail.net>

Program keypress;

uses Crt;
begin
  repeat
    { Fill the screen until a key is hit }
    Write('Xx');
  until KeyPressed;
end.

Quote
>                    -Rodrigo Strougo (rstro...@cc.gatech.edu)

Re:Keyboard Read


Quote
In article <475gan$...@solaria.cc.gatech.edu>, rstro...@cc.gatech.edu (Rodrigo Strougo) writes:

> Does anyone known if there is a Pascal equivelent to the BASIC command INKEY$ ?
> This command checks the keyboard buffer for any keystrokes and returns the value
> to the module that called it. This command would be useful if one wanted to check
> the keyboard and the mouse while in a loop. This way the user does not have to hit enter after typing in a char. Thanks in advance, Rod.

USES
  CRT;

  function Inkey : word;
  VAR
    Save : word;
  BEGIN
    IF KeyPressed THEN
    BEGIN
      Save:=Ord(ReadKey);

      IF Save=0 THEN { If user pressed some special key }
        Save:=Ord(ReadKey) SHL 8;
    END
    ELSE
      Inkey:=0;
  END;

  This is the Pascal equivalent to INKEY$.

  --Lars M.

Other Threads