DelphiDabbler Code Snippets Database

Snippet Selection

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


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;
  // High bit set when key is pressed => GetKeyState returns -ve value
  Result := Windows.GetKeyState(VirtKeyCode) < 0;

View the whole database.

Go to the DelphiDabbler website.