检查何时按下箭头键? [英] Check when arrow keys are pressed?

查看:36
本文介绍了检查何时按下箭头键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查是否按下了箭头键(不知道,例如右键)?

How can I check if an arrow key (dunno, the right key for example) is pressed?

推荐答案

只需在表单加载时将 KeyPreview 属性设置为 true

Just set the KeyPreview Property to true on Form load

之后您可以使用 KeyDown/KeyPress 事件.

after that you can use the KeyDown / KeyPress event.

    Private Sub main_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    '40 = ArrowkeyDown 38= ArrowKeyUp
    If Not e.KeyValue = 40 AndAlso Not e.KeyValue = 38 Then Exit Sub
    'Key Down / Up Code
End Sub

这篇关于检查何时按下箭头键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆