was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

28 Visitors Online


 
...gleichzeitiges Drücken mehrer Tasten innerhalb einer Form erkennen?
Autor: Radikal, Q3 Team
[ Tip ausdrucken ]  

Tip Bewertung (28):  
     


{
  I would like to detect more than 2 keys being pressed within a form.
  For example I would like to know if the user pressed    time. The onkeydown seems to only check for one or two keys max but surely
  you can determine what keys are currently down.
}

// You can use GetKeyState:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  If 
((GetKeyState(VK_CONTROL) AND 128)=128) and
     
((GetKeyState(VK_F5)      AND 128)=128) and
     
((GetKeyState(ord('8'))   AND 128)=128)
    then
      
ShowMessage('CTRL+F5+8 Pressed');
end;

( Remember: Form1.Keypreview := TRUE )


// Or you can read the entire KeyBoard Status,
// and later check for the three keys:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
   
KeybState: TKeyboardState;
begin
  
GetKeyboardState(Teclado);
  If ( (KeybState[VK_CONTROL] and 128)=128 ) and
     
( (KeybState[VK_F5]      and 128)=128 ) and
     
( (KeybState[Ord('8')]   and 128)=128 )
    then
      
ShowMessage('CTRL+F5+8 Pressed');
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners