且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

keyDown完成后如何获取键盘键号?

更新时间:2023-11-21 11:52:28

问题尚不清楚,但是我可以通过键号"猜测您的意思是原始键标识符(该标识符先于键被识别为状态键,字符键等),称为"扫描代码".您可以将其作为CWnd::OnKeyDown的参数nFlags的低字节来获取;请参阅:

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

另请参见: http://en.wikipedia.org/wiki/Scan_code [
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:
byte scanCode = nFlags & 0xFF;



—SA



—SA