Check for SHIFT key

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Guitarm
Forum Moderator
Posts: 385
Joined: 2004-01-18 15:38

Check for SHIFT key

Post by Guitarm » 2005-11-19 05:10

Is there a specific reason for checking if the SHIFT key is used in HubFrame::onChar?

Like:

Code: Select all

if( (GetKeyState(VK_CONTROL) & 0x8000) )
Or should one check for both like:

Code: Select all

if( (GetKeyState(VK_CONTROL)) || (GetKeyState(VK_CONTROL) & 0x8000) )
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2005-11-19 05:29

I'm not sure I understand exactly what you want.
But if you wanted to check if the shift key is down you would use

Code: Select all

if( (GetKeyState(VK_SHIFT) & 0x8000) ) 
Or should one check for both like:

Code: Select all

if( (GetKeyState(VK_CONTROL)) || (GetKeyState(VK_CONTROL) & 0x8000) )
I don't think that would accomplish anything useful as the info of the return value is stored in the high and the low bit of the return value.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getkeystate.asp wrote: The return value specifies the status of the specified virtual key, as follows:

* If the high-order bit is 1, the key is down; otherwise, it is up.
* If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled
[/code]

Guitarm
Forum Moderator
Posts: 385
Joined: 2004-01-18 15:38

Post by Guitarm » 2005-11-19 05:44

Oh, I misunderstood. The 0x8000 checks if the key is in it's "pressed down" mode. Thanks for clarification.
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."

Locked