VB2010 - KeyDown Events Not Executing
I have a pong type of game and I want the spacebar to pause the game... Here is my code to detect when the space bar is pressed.
Private Sub PongMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyValue = Keys.Space Then
Application.Exit()
End If
End Sub
For some reason the application is not closing... IS 开发者_运维百科there something wrong with this code that I am not seeing?
Thanks
Make sure to check your form's KeyPreview property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx
精彩评论