PollKeyEvent

Get next key event, but does not wait.

Declaration

Source position: keybrdh.inc line 155

  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

Name Description
GetKeyEvent Get the next raw key event, wait if needed.
PutKeyEvent Put a key event in the event queue.

Example

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.