开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜