Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

multiple key press

[es] :: C/C++ programiranje :: multiple key press

[ Pregleda: 2386 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

zarkocgyus
Bar

Član broj: 102691
Poruke: 121
79.143.100.*



+2 Profil

icon multiple key press02.03.2008. u 23:28 - pre 196 meseci
Cao. Zna li neko kako da detektujem vise pritisnutih tastera odjednom u C++ Builder-u.
Pozdrav.
 
Odgovor na temu

X Files
Vladimir Stefanovic
Pozarevac

SuperModerator
Član broj: 15100
Poruke: 4902
*.tekostolac.co.yu.

Jabber: xfiles@elitesecurity.org


+638 Profil

icon Re: multiple key press03.03.2008. u 06:23 - pre 196 meseci
Recimo:
http://tinyurl.com/3b7ct9
--- H ---
Code:

   private:
bool Key81Pressed;
bool Key87Pressed;
bool Key69Pressed;


--- CPP ---
Code:

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
   Key81Pressed = false;
   Key87Pressed = false;
   Key69Pressed = false;
}

void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   // 81=Q, 87=W, 69=E

   if ( !Key81Pressed && Key == 81 )
      Key81Pressed = true;

   if ( !Key87Pressed && Key == 87 )
      Key87Pressed = true;

   if ( !Key69Pressed && Key == 69 )
      Key69Pressed = true;

   if ( Key81Pressed && Key87Pressed && Key69Pressed )
   {
      Key81Pressed = false;
      Key87Pressed = false;
      Key69Pressed = false;
      ShowMessage( "Q W E Pressed" );
   }
}
void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   if ( Key == 81 ) Key81Pressed = false;
   if ( Key == 87 ) Key87Pressed = false;
   if ( Key == 69 ) Key69Pressed = false;
}


...ili pogledaj GetKeyboardState() API, ako ti ovo ne odgovara.

P.S.
Ili, gde god imaš u izrazima konstante tipa:
if ( Key == 81 ) Key81Pressed = false;
... zameni sa odgovarajućim velikim slovom zbog čitljivosti, na primer:
if ( Key == 'Q' ) Key81Pressed = false;
itd...

81 ---> 'Q'
87 ---> 'W'
69 ---> 'E'


[Ovu poruku je menjao X Files dana 03.03.2008. u 07:45 GMT+1]
 
Odgovor na temu

zarkocgyus
Bar

Član broj: 102691
Poruke: 121
79.143.100.*



+2 Profil

icon Re: multiple key press03.03.2008. u 20:16 - pre 196 meseci
He, he.
Hvala na odgovoru. U medjuvremenu sam nasao slicno resenje u nekim primerima
za koje nisam ni znao da ih imam u komp-u.
Pozdrav.
 
Odgovor na temu

[es] :: C/C++ programiranje :: multiple key press

[ Pregleda: 2386 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.