Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Tastenkombination Problem bei Keypress (https://www.delphipraxis.net/128022-tastenkombination-problem-bei-keypress.html)

thomas2009 22. Jan 2009 23:54


Tastenkombination Problem bei Keypress
 
Hallo

wie kann ich überprüfen ob eine Taste ohne Tastenkombination gedrückt wurde ?
Die Pfeil-Rechts Taste soll 2 Funktionen tun
Wenn die Taste alleine gedrückt wird
Und ein mal, wenn die Taste mit Ctrl zusammen gedrückt werden

ssCtrl not in Shift
Delphi-Quellcode:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

if(Key =39)then
    begin
      ShowMessage('Pfeil rechts nur'); // !!!
    end;

if((ssCtrl in Shift) and (Key =39))then
    begin
      ShowMessage('Ctrl + Pfeil rechts'); // OK
    end;
end;
Ich have versucht mit dem Code aber wird nicht angenommen
Delphi-Quellcode:
if((ssCtrl not in Shift) and (Key =39))then // Fehler hier "not in" wird nicht angenommen
    begin
      ShowMessage('Pfeil rechts nur'); // !!!
    end;

turboPASCAL 23. Jan 2009 03:14

Re: Tastenkombination Problem bei Keypress
 
Wie wäre es denn damit:

Delphi-Quellcode:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if((ssCtrl in Shift) and (Key =39))then
  begin
    ShowMessage('Ctrl + Pfeil rechts');
  end else // <--<<
  if(Key =39)then
  begin
    ShowMessage('Pfeil rechts nur');
  end;
end;
;)

Uwe Raabe 23. Jan 2009 07:03

Re: Tastenkombination Problem bei Keypress
 
Es heißt ja auch

Delphi-Quellcode:
if not (ssCtrl in Shift) then


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:50 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz