Sign in Join
Wiki copytemporary

Revision 1 of 1, by Trev on 2-10-2020. The page as it is now.

Check status of special keys/de

Zurück zur Seite Code Beispiele.

Dieser Artikel beschäftigt sich mit der Windowsprogrammierung.

Die Prozeduren ermitteln den Status der Tasten:

Beispiel:

pascal
uses
  Windows, ...;

   ...

function funLowOrderBitSet(intWert: integer): boolean; inline;
begin
  Result := (intWert and 1 > 0);
end;

// ermittelt, ob die Caps-Lock-Taste aktiv ist
function funCapsLock: boolean;
begin
  Result := funLowOrderBitSet(GetKeyState(VK_CAPITAL));
end;

// ermittelt, ob die Einfügen-Taste aktiv ist
function funInsertOn: boolean;
begin
  Result := funLowOrderBitSet(GetKeyState(VK_INSERT));
end;

// ermittelt, ob die Num-Lock-Taste aktiv ist
function funNumLock: boolean;
begin
  Result := funLowOrderBitSet(GetKeyState(VK_NUMLOCK));
end;

// ermittelt, ob die Scoll-Lock-Taste aktiv ist
function funScrollLock: boolean;
begin
  Result := funLowOrderBitSet(GetKeyState(VK_SCROLL));
end;
  
  ...

From the Free Pascal wiki, page "Check status of special keys/de", as it stood on 2020-02-10 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.