|
-
Oct 28th, 2005, 05:09 AM
#1
Thread Starter
Lively Member
Distinguish Keypresses without Direct X
Is there a way to distinuish between left and right shifts, Ctrls and Alts - without resorting to using Direct X?
-
Oct 28th, 2005, 06:05 AM
#2
Fanatic Member
Re: Distinguish Keypresses without 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
-
Oct 28th, 2005, 11:46 AM
#3
Re: Distinguish Keypresses without Direct X
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.
-
Oct 28th, 2005, 01:09 PM
#4
Fanatic Member
Re: Distinguish Keypresses without Direct X
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.
-
Oct 28th, 2005, 01:14 PM
#5
Re: Distinguish Keypresses without Direct X
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.
-
Oct 28th, 2005, 01:37 PM
#6
Re: Distinguish Keypresses without Direct X
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).
-
Oct 29th, 2005, 12:41 PM
#7
Re: Distinguish Keypresses without Direct X
so anyone please explain how to distinguish them in Win 9x.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|