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

# PutKeyEvent

Put a key event in the event queue.

## Declaration

Source position: keybrdh.inc line 146

`procedure PutKeyEvent(`
`KeyEvent: TKeyEvent`
`);`

## Description

PutKeyEvent adds the given KeyEvent to the input queue. Please note that depending on the implementation this can hold only one value, i.e. when calling PutKeyEvent multiple times, only the last pushed key will be remembered.

## Errors

None

## See also

PollKeyEvent |  | Get next key event, but does not wait.
GetKeyEvent |  | Get the next raw key event, wait if needed.

## Example

    program example5;

    { This program demonstrates the PutKeyEvent function }

    uses keyboard;

    Var
      K,k2 : TKeyEvent;

    begin
      InitKeyBoard;
      Writeln('Press keys, press "q" to end.');
      K2:=0;
      Repeat
        K:=GetKeyEvent;
        If k<>0 then
          begin
          if (k2 mod 2)=0 then
            K2:=K+1
          else
            K2:=0;
          K:=TranslateKeyEvent(K);
          Writeln('Got key : ',KeyEventToString(K));
          if (K2<>0) then
            begin
            PutKeyEvent(k2);
            K2:=TranslateKeyEVent(K2);
            Writeln('Put key : ',KeyEventToString(K2))
            end
          end
      Until (GetKeyEventChar(K)='q');
      DoneKeyBoard;
    end.

Documentation generated on: Feb 26 2014