检查何时按下箭头键?

时间:2011-04-06 23:37:26

标签: vb.net winforms visual-studio

如何检查是否按下了箭头键(dunno,右键)?

1 个答案:

答案 0 :(得分:1)

只需在表单加载

上将KeyPreview属性设置为true即可

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

    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