tags:

views:

49

answers:

1

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

+1  A: 

Make sure to check your form's KeyPreview property.

http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx

BP
Thanks! That was it!
Johnny Whisman