GetKeyEventShiftState

Return the current state of the shift keys.

Declaration

Source position: keybrdh.inc line 183

  function GetKeyEventShiftState(KeyEvent: TKeyEvent) : Byte;

Description

GetKeyEventShiftState returns the shift-state values of the given KeyEvent. This can be used to detect which of the modifier keys Shift, Alt or Ctrl were pressed. If none were pressed, zero is returned.

Note that this function does not always return expected results; In a UNIX X-Term, the modifier keys do not always work.

Errors

None.

See also

Name Description
GetKeyEvent Get the next raw key event, wait if needed.
GetKeyEventChar Get the character key part of a key event.
GetKeyEventCode Translate function key part of a key event code.
GetKeyEventFlags Extract the flags from a key event.
GetKeyEventUniCode Return the Unicode key event.

Example

Program Example3;
{ Program to demonstrate the GetKeyEventShiftState function. }
Uses keyboard;
Var
  K : TKeyEvent;
  S : Byte;
begin
  InitKeyBoard;
  Write('Press keys combined with CTRL/SHIFT/ALT');
  Writeln(', or press "q" to end.');
  Repeat
    K:=GetKeyEvent;
    K:=TranslateKeyEvent(K);
    S:=GetKeyEventShiftState(K);
    If (S=0) then
      Writeln('No special keys pressed')
    else
      begin
      Writeln('Detected special keys : ',ShiftStateToString(K,False));
      Writeln('Got key : ',KeyEventToString(K));
      end;
  Until (GetKeyEventChar(K)='q');
  DoneKeyboard;
end.