Is there a way to distinuish between left and right shifts, Ctrls and Alts - without resorting to using Direct X?
Printable View
Is there a way to distinuish between left and right shifts, Ctrls and Alts - without resorting to using Direct X?
You can use the Keyascii asignments that are numbers. You will have to find a list of all the numbers for each key because I don't have one, but here is the code to run the Keyascii.
VB Code:
Private Sub form_KeyPress(KeyAscii as Integer) If KeyAscii = 'here is where you find the number of the key and enter it End Sub
KeyAscii doesnt support it, paralinx. You have to use the KeyDown/KeyUp events, or use the GetAsyncKeyState API.
DirectInput is much better because it retrieves input directly from your input devices rather than through Window messages. On top of that, it allows you to press multiple keys at once very easily.
Hm, well I thought he was trying to tell the difference between the left and right shift keys, the Keydown event only has one vbKeyShift and vbKeyControl.
Actually it does support Alt. It's KeyCode is 18 ;)
And thats the problem with the KeyDown/KeyUp events. Even though theres a left and right control/alt/shift, it's considered as the same KeyCode. DirectInput on the other hand has them as 2 separate keycodes so you can distinguish one from the other. Like I said it's way better.
You can, as already mentioned, use the GetAsyncKeyState function. First use the KeyDown event and check if Shift (for example) is pressed, you can then call GetAsyncKeyState and pass VK_LSHIFT to check if it's the left shift key that has been pressed, if not VB_RSHIFT must have been pressed (this does not work on Win9x).
so anyone please explain how to distinguish them in Win 9x.