DelphiDabbler Code Snippets Database

Snippet Selection

The following snippets from the Code Snippets Database have been requested.

IsKeyPressed

Checks if the key identified by VirtKeyCode is being pressed. VirtKeyCode must be either a virtual key code or an ASCII value.

function IsKeyPressed(const VirtKeyCode: Integer): Boolean;
begin
  // High bit set when key is pressed => GetKeyState returns -ve value
  Result := Windows.GetKeyState(VirtKeyCode) < 0;
end;

View the whole database.

Go to the DelphiDabbler website.