-
Key Down Problem
For some strange reason i am having problems with the following code:
Code:
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Right
Call CurrentBlock.Right()
Case Keys.Left
Call CurrentBlock.Left()
Case Keys.Up
Call CurrentBlock.Rotate()
Case Keys.Down
Call CurrentBlock.Down()
Case Else
Exit Sub
End Select
End Sub
Its not executing what it should be when the keys are presses. Ive put a breakpoint on it and its not even firing at all when they keys are pressed but i can work out why this is.
Appreciate any ideas.
-
Re: Key Down Problem
try setting form .keypreview to true
-
Re: Key Down Problem
Nope still no luck, Cheers anyways
-
Re: Key Down Problem
Do you have buttons on your form? They will take the focus and block Form Keypresses.
-
Re: Key Down Problem
Ye i have one button. How do i solve this problem if it is the button?
-
Re: Key Down Problem
I have also now added a handler for the buttons key down event however this works for most keys but still not the arrow keys.
I spose this will do but if anyone knows a way of getting the arrow keys to work that would be great.
-
Re: Key Down Problem
I answered this a few days ago when it was asked by another member. Here is that thread.
http://www.vbforums.com/showthread.p...ighlight=arrow