|
-
Sep 9th, 2000, 07:14 AM
#1
Thread Starter
Addicted Member
Hiyas,
How do I go about detecting if more than one key is pressed than once ? I'm making a game here and I just realised this... hehe. =)
-Git
-
Sep 9th, 2000, 07:18 AM
#2
_______
<?>
Code:
Option Explicit
Public x As Integer
Private Sub Text1_KeyPress(KeyAscii As Integer)
'a has been pressed x amount of times
If KeyAscii = 97 Then x = 1
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 9th, 2000, 07:24 AM
#3
Thread Starter
Addicted Member
Actually I mean say if you're using the cursor keys, and you hold down two at once.
-
Sep 9th, 2000, 08:13 AM
#4
Ex-Super Mod'rater
This is quite easy cos I am doing the same thing but I am only using one curosr key at a time. This is like the code I used: ( it might help)
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_DOWN = &H28
Private Const VK_LEFT = &H25
If GetAsyncKeyState(VK_DOWN) <> 0 and GetAsyncKeyState(VK_LEFT) <> 0 Then
End If
if you have any trouble with this code then email me and I will sort it out. Or if you want I will send you the source code for my game. E-mail to [email protected]
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Sep 9th, 2000, 08:14 AM
#5
Use GetAsyncKeyState API.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyA) And GetAsyncKeyState(vbKeyB) Then MsgBox ("Both A and B were pressed at the same time")
End Sub
-
Sep 9th, 2000, 08:16 AM
#6
Ex-Super Mod'rater
Oh yea I forgot to put the code in a timer
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Sep 9th, 2000, 08:28 AM
#7
Thread Starter
Addicted Member
Cool, I'll try it later. Thanks everyone. =)
-
Sep 9th, 2000, 08:31 AM
#8
Ex-Super Mod'rater
Just to make sure u know its only the If...Then That goes in the Timer
Could you help me by going to my form. Thanx
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Sep 9th, 2000, 01:19 PM
#9
Also, the constants VK_DOWN, VK_LEFT etc. are already defined in VB as vbKeyDown and vbKeyLeft so you don't need to add them.
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
|