VB2010 - KeyDown 事件未执行
我有一个乒乓球类型的游戏,我想要空格键来暂停游戏...这是我的代码来检测何时按下空格键。
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
由于某种原因,应用程序没有关闭...这段代码是否有我没有看到的问题?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请务必检查表单的 KeyPreview 属性。
http://msdn.microsoft.com/ en-us/library/system.windows.forms.form.keypreview.aspx
Make sure to check your form's KeyPreview property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx