Click here to Skip to main content
15,742,377 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How to check KeyBoard Key Number example 17=w
VB
1=Esc
2=1
3=2
4=3
5=4
6=5
7=6
8=7
9=8
10=9
11=0
so on which are standard values.
when WM_KEYDOWN event is called.
Posted
Comments
Sergey Alexandrovich Kryukov 10-Feb-12 1:27am    
Not clear.
--SA
chaiein 10-Feb-12 1:32am    
WM_KEYDOWN is called when any key in the keyboard is pressed. how to find which key is pressed?
Sergey Alexandrovich Kryukov 10-Feb-12 1:34am    
Aha. You should tell what exactly do you mean by "which" key, but I think I can guess by your example above. Please see my answer.
--SA

1 solution

The question is not clear, but I can guess by "key number" you mean a raw key identifier (which comes into play before a key is recognized as a status key, character key, etc.), which is called "scan code". You can get it as lower byte of the parameter nFlags of CWnd::OnKeyDown; please see:

http://msdn.microsoft.com/en-us/library/983st27a%28v=vs.100%29.aspx[^].

See also: http://en.wikipedia.org/wiki/Scan_code[^].

You can extract scan code from nFlags like this:
C++
byte scanCode = nFlags & 0xFF;


—SA
 
Share this answer
 
v5
Comments
chaiein 10-Feb-12 1:47am    
Ya thank you:)
Sergey Alexandrovich Kryukov 10-Feb-12 2:11am    
Glad to help you.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900