-
Jul 14th, 2009, 11:51 AM
#1
Thread Starter
Addicted Member
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.
-
Jul 14th, 2009, 11:54 AM
#2
Re: Key Down Problem
try setting form .keypreview to true
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 14th, 2009, 12:04 PM
#3
Thread Starter
Addicted Member
Re: Key Down Problem
Nope still no luck, Cheers anyways
-
Jul 14th, 2009, 12:09 PM
#4
Re: Key Down Problem
Do you have buttons on your form? They will take the focus and block Form Keypresses.
-
Jul 14th, 2009, 12:28 PM
#5
Thread Starter
Addicted Member
Re: Key Down Problem
Ye i have one button. How do i solve this problem if it is the button?
-
Jul 14th, 2009, 03:15 PM
#6
Thread Starter
Addicted Member
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.
-
Jul 14th, 2009, 03:22 PM
#7
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
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
|