Difference between revisions of "GetKeyState"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function GetKeyState(const VKey: Byte): Boolean; </source> ==Availability== SCAR Divi 3.00 > Current ==Description== Gets t...")
(No difference)

Revision as of 15:12, 10 November 2012

Definition

function GetKeyState(const VKey: Byte): Boolean;

Availability

SCAR Divi 3.00 > 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