Advertisement

Multiple Keys Down in Visual C++

Started by May 24, 2001 08:43 PM
5 comments, last by Live2Code 23 years, 8 months ago
I am using keys to control the camera of my MFC OpenGL app. When a key is pressed, I incriment/decriment the appropriate rotation state variable and refresh the scene. The problem is that only one key can be pressed at a time. If you press and hold two keys, it only thinks you have the first one held down. Help. void CGLSample1View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if (nChar==''A'') { ... } else if(nChar==''D'') { ... } else if(nChar==''W'') { ... } else if(nChar==''S'') { ... } else if(nChar==''E'') { ... } else if(nChar==''Q'') { ... } CView::OnKeyDown(nChar, nRepCnt, nFlags); }
while(my_life[years++]!=null) { code();}
int ispressed = GetAsyncKeyState() & 0x8000;
check it out...

Arkon
[QSoft Systems]
Advertisement
Just remove the else''s
it won''t help to remove the else''s
cuz the nChar has just one value at a time
altough it can use logic or...but that something else

Arkon
[QSoft Systems]
Arkon, could you be a little more specific?
while(my_life[years++]!=null) { code();}
register a shortcut in the accelerator table.

then you will get an accelerator message if more keys are pressed at the same time.

or you can use direct input .. or GetAsyncKeyState()

{ Stating the obvious never helped any situation !! }
Advertisement
Thanks, the GetAsyncKeyState() was what I needed.
while(my_life[years++]!=null) { code();}

This topic is closed to new replies.

Advertisement