Jump to content
  • Advertisement
Sign in to follow this  
helix

Keypad Enter's virtual key code?

This topic is 4856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not seeing a way to differentiate the enter key on the numpad from the regular enter key. I checked the value passed in upon pressing it and it basically corresponds to VK_RETURN -- which is the same as the other enter key. I looked at the virtual key code chart on MSDN (HERE) and nothing is popping out at me. VK_SEPARATOR looks logical due to its proximity to all the other keypad codes (smack in the middle of them), but that doesn't appear to be the case. Maybe you can tell via scan codes, but if that's the case, that still doesn't explain the lack of a virtual key for it. I'll live if there is no way to tell the two enter keys apart but it sure seems like there should be a way.

Share this post


Link to post
Share on other sites
Advertisement
The scan code is exactly what you are looking for. There are multiple scan codes that map to the same virtual key...scan codes are lower level whereas virtual keycodes are meant to abstract away some of the differences between keyboards and other input devices. If you detect a VK_RETURN just look at the lParam to figure out which is being pressed. Trial-and-error works fine or you can read through the docs for WM_KEYDOWN and this if you really want the inside scoop (check out the Keyboard Scan Code Specification doc).

Share this post


Link to post
Share on other sites
Note that lParam carries several flags. Numpad keys usually have the extended bit set (0x1000000).

So if you get a VK_RETURN with lParam & 0x1000000 it's the numpads enter key; if the bit is not set it's the standard enter key.

Share this post


Link to post
Share on other sites
What about if I want to test without knowing the lParam scan code? That is my problem. I do the key translation far removed from the message pump and so I don't have the scan code anymore when I'm using my test.

Share this post


Link to post
Share on other sites
Then you're out of luck. Essential information has been dismissed that way and there's no way you can recover it.

Try to pass at least that bit flag additionally. It helps you distinguish most numpad keys from the default ones.

Also the lParam & 0xff0000 mask helps you determine if the left or right shift/alt/control key was pressed.

Share this post


Link to post
Share on other sites
Ok, thanks. In that case, I don't care about differentiating between the two enter keys. But it still seems odd to me that MS didn't define a virtual key for the keypad enter since they did for every other key (including some stuff that I've never even heard of). But it's hardly important for my purposes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!