I am using Windows XP pro SP3. Standard english keyboard. I live in the USA; never touched the keyboard settings. Stock install. So, when I press check the scancodes my program is returning they are as follows:
A = 30
S = 31 D = 32 F = 33 G = 34When I check the microsoft specification (page 11 of the document:: http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc ) It says:
开发者_运维问答A = 31
S = 32 D = 33 F = 34 G = 35They are off by 1! Any ideas why?
The Microsoft Keyboard Scan Code Specification you quoted has six columns. For the A key:
key location: 31
keyboard: A
scan 1 make: 1E
scan 1 break: 9E
scan 2 make: 1C
scan 2 break: F0 1C
It looks like that "scan 2" set is an alternate hardware scan code that's different from the original IBM PC scan code ("scan 1"). Note that the "key location" is 31 and the "scan 1 make" is 30. This might help explain what you're seeing with the values you originally posted. Perhaps you could try looking at keys such as Esc and ` that are quite different in each set (and not just off by one, which I think is misleading).
You didn't say which API or Windows message you were using to get the scan code values you reported, but if you look in the detailed documentation for whatever you're using you might find more information.
Is the keyboard faulty at the hardware level or there is a problem with the keyboard driver can you ascertain?
精彩评论