11

We have 2 CTRL/ALT/SHIFT buttons on our keyboard. But there are VK_CONTROL/VK_LCONTROL/VK_RCONTROL available in the win api. So which value is default for the VK_CONTROL? VK_LCONTROL (left) or VK_RCONTROL (right)? Or maybe it choses value depending on some situation? Can't find the answer neither in MSDN nor in Google.

I think it doesn't matter in connection with CTRL - they are alternating, but it makes difference with e.g. ALT.

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
tobi
  • 1,944
  • 6
  • 29
  • 48

2 Answers2

8

Text from WinUser.h:

VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
Used only as parameters to GetAsyncKeyState() and GetKeyState().
No other API or message will distinguish left and right keys in this way.

arx
  • 16,686
  • 2
  • 44
  • 61
  • but as I can see there the three of them have three different values. Moreover, the SendInput() does distinguish left and right. E.g. in my language I can't write some letter using left ALT but I am able to do that using right ALT, and with SendInput when I send left ALT it doesn't print what it should, but with right ALT it does. – tobi Jul 15 '12 at 13:30
  • 1
    You're right, that comment from the header is US-centric. The left and right ALT are treated as separate keys on British keyboards too, though SHIFT and CTRL aren't. More to the point, what do you actually want to do? – arx Jul 15 '12 at 13:51
  • I am allowing users to send some text using SendInput() (with some special keys like ctrl, alt etc.), and I wonder whether I should allow the users to use the three values for the ctrl and alt or less, but I think it's more like a discuss than a Q&A format. – tobi Jul 15 '12 at 14:11
  • 1
    The right-hand Alt key is not the same as Right-Alt. On many keyboards, the right-hand Alt key is actually AltGr. – Raymond Chen Jul 15 '12 at 14:47
  • @RaymondChen what is 'AltGr'? – tobi Jul 15 '12 at 16:08
  • 1
    @tobi: AltGr is the right-hand Alt key with a different label. In some locales, Windows treats it as a modifier key rather than an Alt key. For example, in the UK Alt+E opens the Edit menu but AltGr+E types É. However, from the point of view of low-level functions like `GetKeyState` it's just the right-hand Alt key `VK_RMENU`. Wikipedia has [more details](http://en.wikipedia.org/wiki/AltGr_key). – arx Jul 15 '12 at 16:29
2

As far as I can tell these constants are declared in WinUser.h

#define VK_LSHIFT         0xA0
#define VK_RSHIFT         0xA1
#define VK_LCONTROL       0xA2
#define VK_RCONTROL       0xA3
#define VK_LMENU          0xA4
#define VK_RMENU          0xA5
Blablablaster
  • 3,238
  • 3
  • 31
  • 33
  • but the VK_CONTROL is 0x11, so it's different from those two above. But we don't have 3 CTRLs on keyboard. – tobi Jul 15 '12 at 13:34