我正试图在Visual Basic(VS 2010)中编写一个程序来响应箭头键。我知道在Java中有关键的监听器,但不知道在VB中是否存在这样的事情以及如何对它进行编码。请给我看一些例子。 谢谢。Visual Basic密钥监听器
0
A
回答
2
如果您正在执行winforms,请将表单的KeyPreview属性设置为true,然后设置KeyDown事件。您的代码将如下所示:
Dim previousKey As Keys? = Nothing
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Up Then
'up arrow
End If
If e.KeyCode = Keys.Left Then
'left arrow
If Not previousKey Is Nothing And previousKey = Keys.Up Then
'Up arrow and then Left Arrow
MessageBox.Show("there, that's better")
End If
End If
If e.KeyCode = Keys.Right Then
'right arrow
End If
If e.KeyCode = Keys.Down Then
'down arrow
End If
'After everything is done set the current key as the previous key.
previousKey = e.KeyCode
End Sub
相关问题
- 1. Java:向JFrame添加密钥监听器
- 2. 用事件监听器迭代ListBox的Visual Basic
- 3. 列表中的Visual Basic 2010事件监听器
- 4. 如何实现全局密钥监听器?
- 5. JavaFx聊天TextField和按钮密钥监听器
- 6. 听取CAPS密钥
- 7. Visual Basic中的关键监听器 - 给予回应时,2个键按下
- 8. Doctrine - 使用dql监听器加密
- 9. jxBrowser为JavaFX添加密钥侦听器
- 10. Visual Basic转换密码
- 11. TCP监听器停止监听
- 12. Laravel监听器监听多个事件
- 13. CommunicationState监听器?
- 14. 器件监听器
- 15. 需要输入字段的jQuery监听器 - 密钥和更改不起作用
- 16. Visual Basic服务器
- 17. Javafx TreeView监听器
- 18. JavaFX TextField监听器
- 19. 监听器丢失
- 20. GridView - Onclick监听器
- 21. Symfony onKernelException监听器
- 22. AS3 - MouseWheelDown监听器
- 23. ListSelectionModel和监听器
- 24. ExtJS CheckboxSelectionModel监听器
- 25. 异常监听器
- 26. 位置监听器
- 27. Glide onProgressUpdate监听器
- 28. ListView“onPopulate”监听器?
- 29. Undertow HTTPS监听器
- 30. Efficientadapter OnItemClick监听器
console?的WinForms? WPF? XNA? –