我正在尝试捕捉快捷键。我需要解释如何KeyDown Events
管理。让我们以此为例:
Private Sub SoldeOuvertFou_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control And e.KeyCode = Keys.W Then
MessageBox.Show("Ctrl+W")
End If
If e.Control And e.KeyCode = Keys.F5 Then
MessageBox.Show("Ctrl+F5")
End If
End Sub
完美运行。无论我先按哪个或按多少次,它们MessageBox
都会弹出。现在,如果我只是更改 sub 内的顺序:
Private Sub SoldeOuvertFou_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control And e.KeyCode = Keys.F5 Then
MessageBox.Show("Ctrl+F5")
End If
If e.Control And e.KeyCode = Keys.W Then
MessageBox.Show("Ctrl+W")
End If
End Sub
用这种方法,只会Ctrl+F5
弹出。没有办法Ctrl+W
出现......知道为什么吗?