Autor Beitrag
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Do 15.08.02 15:02 
Hallo!

sicherlich ziemlich banal die Frage. Wie kann ich mehrere Tasten gleichzeitig abfragen. Ich mach das bissher mit Key: Char von Form1.OnKeyPress

Geht das auch besser?
Black Lightning
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 69



BeitragVerfasst: Do 15.08.02 17:11 
ich hab mal so was in einem programm verwendet:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
type...
  procedure steuerung(Sender: TObject; var Key: Word;
      Shift: TShiftState);
.
.
.
implementation

procedure TForm1.steuerung(Sender: TObject; var Key: word;
  Shift: TShiftState);
Begin
.
.
if (ssalt in shift) and (ssCtrl in shift) then
.
.
end;


meinst du sowas?

mfg
Black Lightning

_________________
--erst programmieren, dann denken, dann debuggen--
lemming Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Fr 16.08.02 09:13 
Ich meinte eingentlich zwei Tasten gleichzeitig gedrückt halten, wie z.B. a und gleichzeitig l etc. Ich machs jetzt mit OnKeyDown. da kann ich die Cursortastenabfragen. Trotzdem aber immer nur eine Taste :/
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Fr 16.08.02 09:44 
In der Praxis wird ein User nicht zwei Tasten gleichzeitig drücken. Daher generiert Windows für jeden Tastendruck eine Extranachricht.
Ein üblicher Vorgang ist, ein array[0..255] of boolean zu nehmen, und im onkeydown dann array[key] auf true zu setzen und im keyup auf false. Dann musst du einen Schleifendurchlauf machen, um zu gucken, welche Tasten aktiv sind. So kannst du also zum Beispiel einfach abfragen, ob gerade a und l gedrückt sind.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
lemming Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mo 19.08.02 11:18 
Yeah danke! Das klappt.

Was für die FAQ:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  keyCount: Integer;
begin
  Label1.Caption := '';
  KeyArray[key] := True;

  for keyCount := 0 To 255 Do
  begin
    if KeyArray[keyCount] = True Then Label1.Caption := Label1.Caption + Chr(keyCount);
  end;
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  KeyArray[key] := False;
end;
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 19.08.02 11:45 
Hallo,

mit GetKeyboardState und GetKeyState kannst Du den Status auch abfragen.

Gruß
TINO