[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'Crt' (#rtl)

KeyPressed

Check if there is a keypress in the keybuffer

Declaration

Source position: crth.inc line 71

function KeyPressed: Boolean;

Description

Keypressedscans the keyboard buffer and sees if a key has been pressed. If this is the case, Trueis returned. If not, Falseis returned. The Shift, Alt, Ctrlkeys are not reported. The key is not removed from the buffer, and can hence still be read after the KeyPressedfunction has been called.

Errors

None.

See also

ReadKey

  

Read key from keybuffer

Example

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.