GetKeyState

From SCAR Divi Manual
Revision as of 15:14, 10 November 2012 by Freddy (talk | contribs)
Jump to: navigation, search

Definition

function GetKeyState(const VKey: Byte): Boolean;

Availability

SCAR Divi 3.35 > Current

Description

Gets the state of a key asynchronously from the active client. This means that it will return true if the key was pressed since the last time you called the function.

Example

begin
  repeat
    Wait(500)
  until GetKeyState(VK_DOWN);
  WriteLn('Pressed down');
end.

Implementations

IsArrowDown

function IsArrowDown(const Num: Byte): Boolean;
begin
  Result := False;
  case Num of
    0: Result := GetKeyState(VK_UP);
    1: Result := GetKeyState(VK_RIGHT);
    2: Result := GetKeyState(VK_DOWN);
    3: Result := GetKeyState(VK_LEFT);
  end;
end;

IsFKeyDown

function IsFKeyDown(const Num: Byte): Boolean;
begin
  Result := False;
  if (Num > 0) and (Num < 25) then
    Result := GetKeyState(VK_F1 + Num - 1);
end;

IsNumpadKeyDown

function IsNumpadKeyDown(const Num: Byte): Boolean;
begin
  Result := False;
  if (Num >= 0) and (Num =< 9) then
    Result := GetKeyState(VK_NUMPAD0 + Num);
end;

See Also