开发者

VB2010 - KeyDown Events Not Executing

开发者 https://www.devze.com 2023-01-08 06:09 出处:网络
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.

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

精彩评论

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