Hi, I am using this to make the object 'Pos' move around a form which has buttons on it. When a button is pressed this stops working, is there anyway to stop this from happening, also using the arrow keys does not work and stops the wasd keys from working. I have tried enabling and disabling the buttons, but this does not work.
Thanks
Code:
Private Sub trapKey(ByVal sender As Object, ByVal e As KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.S Or e.KeyData = Keys.Down Then
If Pos.Top < 675 Then
Pos.Top = Pos.Top + 5
End If
ElseIf e.KeyData = Keys.W Or e.KeyData = Keys.Up Then
If Pos.Top > 215 Then
Pos.Top = Pos.Top - 5
End If
ElseIf e.KeyData = Keys.A Or e.KeyData = Keys.Left Then
If Pos.Left > 20 Then
Pos.Left = Pos.Left - 5
End If
ElseIf e.KeyData = Keys.D Or e.KeyData = Keys.Right Then
If Pos.Left < 482 Then
Pos.Left = Pos.Left + 5
End If
End If
End Sub
Thanks
Last edited: