2011-04-06 111 views
0

如何檢查箭頭鍵(例如dunno,右鍵)是否被按下?檢查方向鍵何時被按下?

+0

嗯,怎麼樣[結合的keydown聽者](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx)? – 2011-04-06 23:41:19

+0

可能的重複[如何知道箭頭鍵是否被按下而未被釋放?](http://stackoverflow.com/questions/4469939/how-do-i-know-if-a-arrow-key-was -pressed-and-not-released) – 2011-04-07 00:13:21

+0

閱讀本文 http://stackoverflow.com/questions/5589130/check-if-delete-key-is-pressed/7527570#7527570 – 2011-09-23 10:30:15

回答

1

後,您可以使用在KeyDown/KeyPress事件剛剛成立的KeyPreview屬性爲true窗體加載

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