EtienneDufresne
Programmer
Hi,
I'm working on a personal project using Borland C++ Builder 6. This project consists of a plain form on which I draw a circle with a direction line and I make it move using the keyboard. I currently have some keys mapped to move the circle. I use the event called OnKeyDown on the main form to manage the key pressed.
'w' : Move the circle forward in the direction pointed by the line.
's' : Move the circle backward from the direction pointed by the line.
'a' : Rotates the circle Counter Clock Wise.
'd' : Rotates the circle Clock wise.
For the moment, if I press and hold down any of these keys the corresponding action is executed periodically which fine. (ex: pressing and holding down 'w' makes the circle moves forward on the form until I release the key) That means the OnKeyDown event is happens periodically if I hold down a key.
If I press any other key while I'm holding down 'w' the OnKeyDown event does not see it. I would like to be able to move the cicle forward while rotating CCW or CW. This would require to detect which 2 keys are pressed.
How can I detect that 'w' and 'd' are pressed at the same time?
Here is my OnKeyDown even handler code:
void __fastcall TFDisplay::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
if(Key == 'd' || Key == 'D')
{
Particule1->RotCCW();
}
if(Key == 'a' || Key == 'A')
{
Particule1->RotCW();
}
if(Key == 'w' || Key == 'W')
{
MoveForward();
}
if(Key == 's' || Key == 'S')
{
MoveBackward();
}
}
The TShiftState parameter checks the state of the Alt, Ctrl and Shift key. I'm looking to do the same thing with letters. (ex: if 'w' is held down and 'd' is pressed rotated CCW and move forward).
I looked in the online help of Borland for any information. I found something called:"IOTAKeyboardBinding::BindKeyboard" I read a bit about that but whenever I try to declare an instance of IOTAKeyboardBinding the compiler cannot find it.
Well that's about it, thank you very much for any help you may provide!
Etienne Dufresne
I'm working on a personal project using Borland C++ Builder 6. This project consists of a plain form on which I draw a circle with a direction line and I make it move using the keyboard. I currently have some keys mapped to move the circle. I use the event called OnKeyDown on the main form to manage the key pressed.
'w' : Move the circle forward in the direction pointed by the line.
's' : Move the circle backward from the direction pointed by the line.
'a' : Rotates the circle Counter Clock Wise.
'd' : Rotates the circle Clock wise.
For the moment, if I press and hold down any of these keys the corresponding action is executed periodically which fine. (ex: pressing and holding down 'w' makes the circle moves forward on the form until I release the key) That means the OnKeyDown event is happens periodically if I hold down a key.
If I press any other key while I'm holding down 'w' the OnKeyDown event does not see it. I would like to be able to move the cicle forward while rotating CCW or CW. This would require to detect which 2 keys are pressed.
How can I detect that 'w' and 'd' are pressed at the same time?
Here is my OnKeyDown even handler code:
void __fastcall TFDisplay::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
if(Key == 'd' || Key == 'D')
{
Particule1->RotCCW();
}
if(Key == 'a' || Key == 'A')
{
Particule1->RotCW();
}
if(Key == 'w' || Key == 'W')
{
MoveForward();
}
if(Key == 's' || Key == 'S')
{
MoveBackward();
}
}
The TShiftState parameter checks the state of the Alt, Ctrl and Shift key. I'm looking to do the same thing with letters. (ex: if 'w' is held down and 'd' is pressed rotated CCW and move forward).
I looked in the online help of Borland for any information. I found something called:"IOTAKeyboardBinding::BindKeyboard" I read a bit about that but whenever I try to declare an instance of IOTAKeyboardBinding the compiler cannot find it.
Well that's about it, thank you very much for any help you may provide!
Etienne Dufresne