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

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

PutKeyEvent

  

Put a key event in the event queue.

GetKeyEvent

  

Get the next raw key event, wait if needed.

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.

Documentation generated on: Jun 22 2020