Autor Beitrag
stratege15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58



BeitragVerfasst: Mo 01.03.04 14:50 
in spielen z.b. muss man ja schonmal 2 tasten gleichzeitig drücken .. nur kann man dies in delphi weder mit onkeypress noch mit onkeydown ermitteln .. wie dann?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mo 01.03.04 15:01 
ich denke schon, dass beide Tasten das keydown-ereignis auslösen...
am besten erstellst du ein array[0..255] of boolean; in dem die Werte der Tasten gespeichert sind, dass du beim onkeydown auf true und beim onkeyup wieder auf false setzt...
stratege15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58



BeitragVerfasst: Mo 01.03.04 15:13 
danke .. hast mich auf ne idee gebracht:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=50 then
timer1.enabled:=true;
if key=51 then
timer2.enabled:=true;
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=50 then
timer1.enabled:=false;
if key=51 then
timer2.enabled:=false;
end;
doubleq
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Do 04.03.04 17:09 
Nicht so umständlich - einfach GetAsyncKeyState benutzen.
Auszug aus der Win32-API-Referenz:

The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.

SHORT GetAsyncKeyState(int vKey);

Return Values

If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. The return value is zero if a window in another thread or process currently has the keyboard focus.

Gruß DoubleQ
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Do 04.03.04 17:24 
Brainiac
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 04.03.04 17:26 
Für die WinAPI wäre ich auch.
Wenn's größer werden soll, dann vielleicht DierctInput. Da kann man wenigstens auch zwischen linker/rechter Shifttaste unterscheiden.

Kann mir eigentlich mal jemand den Unterschied zwischen GetAsyncKeyState und GetKeyState erklären.
Von den Parameters sind die jedenfalls absolut gleich.