Sign in Join
FPDoc Onlineexperiment

KeyPressed function

In unit Crt

Check if there is a keypress in the keybuffer.

Declaration

pascal
function KeyPressed: Boolean

Description

Keypressed scans the keyboard buffer and sees if a key has been pressed. If this is the case, True is returned. If not, False is returned. The Shift, Alt, Ctrl keys are not reported. The key is not removed from the buffer, and can hence still be read after the KeyPressed function has been called.

Errors

None.

See also

Example: ex2

pascal
Program Example2;
uses Crt;

{ Program to demonstrate the KeyPressed function. }

begin
  WriteLn('Waiting until a key is pressed');
  repeat
  until KeyPressed;
 { The key is not Read,
   so it should also be outputted at the commandline}
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.