Toggle Key Monitoring     D1 D2 D3
A very simple function that returns the toggle status of key. You pass the the key (VK_NUMLOCK, VK_INSERT, etc.) and the it returns whether the key is toggled on or off.
function GetToggleState(Key: integer): boolean;
begin
  Result := Odd(GetKeyState(Key));
end;