如何使用键盘激活按钮?到目前为止,我发现此代码是用于标签而非按钮的
Public Class Form1
Private Sub KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.EventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.W Then
Label1.Text = "W Pressed"
End If
If e.KeyValue = Keys.S Then
Label2.Text = "S Pressed"
End If
End Sub
Private Sub KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.EventArgs) Handles MyBase.KeyUp
If e.KeyValue = Keys.W Then
Label1.Text = "W Not Pressed"
End If
If e.KeyValue = Keys.S Then
Label2.Text = "S Not Pressed"
End If
End Sub
End Class