-
GetKeyState
Hi all, firstly i know that i can use the getkeystate command to detect whether a key is pressed i.e. if getkeystate(vbkeyup) < 0 then...
What i wondered is, does the value returned mean anything usefull? Values i keep getting are 0,1,-128,-127 and i can't see any connection with the state of the key it checks, apart from if it's negative the user is pressing it.
Thanks for any posts.
-
The return value specifies the status of the given 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.
I copied the answer from MSDN
High-order bit=1 means negative
High-order bit=0 means positive
-
Be warned - the key toggled bit is disabled under ME.
-
does this include win 98 too? Is there another way to check for the capslock?
-
Nah, the key toggled bit is disabled just in ME. That aside, that's the way to do it in 98.
-
Re: GetKeyState
This is what I get for GetKeyState, try this:
1 = ON
0 = OFF
-127 = 1 (ON)
-128 = 0 (OFF)