Sign in Join
FPDoc Onlineexperiment

PollKeyEvent function

In unit keyboard

Get next key event, but does not wait.

Declaration

pascal
function PollKeyEvent: TKeyEvent

Description

PollKeyEvent checks whether a key event is available, and returns it if one is found. If no event is pending, it returns 0.

Note that this does not remove the key from the pending keys. The key should still be retrieved from the pending key events list with the GetKeyEvent function.

Errors

None.

See also

Example: ex4

pascal
program example4;

{ This program demonstrates the PollKeyEvent function }

uses keyboard;

Var
  K : TKeyEvent;

begin
  InitKeyBoard;
  Writeln('Press keys, press "q" to end.');
  Repeat
    K:=PollKeyEvent;
    If k<>0 then
      begin
      K:=GetKeyEvent;
      K:=TranslateKeyEvent(K);
      writeln;
      Writeln('Got key : ',KeyEventToString(K));
      end
    else
      write('.');
  Until (GetKeyEventChar(K)='q');
  DoneKeyBoard;
end.

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