Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capture multiple keys.

3 views
Skip to first unread message

Bogdan

unread,
Oct 3, 2004, 9:36:39 AM10/3/04
to
Hello

Does anybody know of a way to capture multiple keys
being pressed at once?

Bogdan.


Vladimir Stefanovic

unread,
Oct 3, 2004, 4:18:26 PM10/3/04
to
Maybe something like this / Untested ! /, so some changes
may possibly be necessary:

--- *.H ---

private: // User declarations

bool Key81Pressed;
bool Key87Pressed;
bool Key69Pressed;

--- *.CPP ---

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

void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
// How can I get this by some func like ord('...') ?
// 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;
}


--


Best regards,
Vladimir Stefanovic

Bogdan <bop...@xnet.ro> wrote in message
news:415f...@newsgroups.borland.com...

Bruce Salzman

unread,
Oct 4, 2004, 8:53:00 PM10/4/04
to
> Does anybody know of a way to capture multiple keys
> being pressed at once?
>

Look at GetKeyboardState() in the Windows API.

Regards,
Bruce


0 new messages