-
July 15th, 2012, 09:59 AM
#1
[RESOLVED] Keyboard key press detection question.
How do I detect what individual key was pressed in my "PeekMessage" loop.
code:
...
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// handle or dispatch messages
if (msg.message == WM_QUIT){
bQuit = TRUE;
}else if (msg.message == WM_LBUTTONDOWN ){
}else if (msg.message == WM_RBUTTONDOWN ){
}else if (msg.message == WM_MBUTTONDOWN ){
}else if (msg.message == WM_KEYDOWN){
// detect pressed key ?
}else if (msg.message == WM_KEYUP){
// detect released key ?
}else{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
...
-
July 15th, 2012, 11:05 AM
#2
Re: Keyboard key press detection question.
You might want to read the documentation about all these
WM_LBUTTONDOWN
WM_RBUTTONDOWN
WM_MBUTTONDOWN
WM_KEYDOWN
WM_KEYUP messages.
Victor Nijegorodov
-
July 15th, 2012, 11:08 AM
#3
Re: Keyboard key press detection question.
-
July 15th, 2012, 12:31 PM
#4
Re: Keyboard key press detection question.
From the msdn documantation , WM_KEYDOWN has a parameter thet conatins a virtual key code , the problem is that I don't know how to read the paramiter to compare the contents with the key codes.
I tried like this:
...
}else if (msg.message == WM_KEYDOWN ){
switch(msg){
case WM_GETDLGCODE:{
if(wParam==VK_ESCAPE){
// code
}
}
}
...
but it doesn't work.
-
July 15th, 2012, 12:40 PM
#5
Re: Keyboard key press detection question.
Have a look at the MSG documentation
Last edited by VictorN; July 15th, 2012 at 12:44 PM.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|