• Advertisement
Sign in to follow this  

[VB.NET 2003] Keydown Sub Issue

This topic is 3812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am not sure how to solve this problem but here it is. I need to be able to respond to mulitple keys being pressed at the same time. Example: Up arrow Left arrow I want to be able to move forward and turn left but for some reason the keydown sub only responds to one key at a time: What I have tried: Dim aUP as boolean = false Dim aDown as boolean = false Dim aLeft as boolean = false Dim aRight as boolean = false Dim cSpeed as double = 0.06F Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As _System.Windows.Forms.KeyEventArgs) _ Handles Form1.KeyDown Select Case e.keycode Case keys.up aUp = True Case keys.down aDown = True Case keys.left aLeft = True Case keys.right aRight = True End Select Move_Around() End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As _System.Windows.Forms.KeyEventArgs) _ Handles Form1.KeyUp Select Case e.keycode Case keys.up aUp = False Case keys.down aDown = False Case keys.left aLeft = False Case keys.right aRight = False End Select End Sub Private Sub Move_Around() If aUp Then Move_Camera(cSpeed) If aDown Then Move_Camera(-cSpeed) If aLeft Then Rotate_Position(cSpeed) If aRight Then Rotate_Position(-cSpeed) End Sub I have not included the Move_Camera and Rotate_Position because they are not needed to solve this problem and they are working just not together at the same time. I am moving from vb 6 to vb.net any help would be greatly appreciated. [Edited by - hartleyw on September 19, 2007 8:46:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement