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:
- Caps Lock oder Shift Lock oder Umschaltsperre oder Feststelltaste
- Insert oder Einfügen-Taste
- Num Lock oder Num-Taste oder Num-Lock-Taste
- Scroll Lock oder Rollen-Taste oder Scroll-Lock-Taste
Beispiel:
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.