GetKeyEvent function
Get the next raw key event, wait if needed.
Declaration
function GetKeyEvent: TKeyEventDescription
GetKeyEvent returns the last keyevent if it is available,
or waits for one if none is available.
A non-blocking version is available in
PollKeyEvent.
The returned key is encoded as a TKeyEvent type variable, and
is normally the physical key scan code, (the scan code is driver
dependent) which can be translated with one of the translation
functions TranslateKeyEvent or TranslateKeyEventUniCode.
See the types section for a description of how the key is described.
Errors
If no key became available (e.g. when the driver does not support it), 0 is returned.
See also
Example: ex1
program example1;
{ This program demonstrates the GetKeyEvent function }
uses keyboard;
Var
K : TKeyEvent;
begin
InitKeyBoard;
Writeln('Press keys, press "q" to end.');
Repeat
K:=GetKeyEvent;
K:=TranslateKeyEvent(K);
Write('Got key event with ');
Case GetKeyEventFlags(K) of
kbASCII : Writeln('ASCII key');
kbUniCode : Writeln('Unicode key');
kbFnKey : Writeln('Function key');
kbPhys : Writeln('Physical key');
kbReleased : Writeln('Released key event');
end;
Writeln('Got key : ',KeyEventToString(K));
Until (GetKeyEventChar(K)='q');
DoneKeyBoard;
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
