使用键盘激活Visual Studio 2019中的按钮

时间:2019-12-25 10:35:45

标签: visual-studio-2019

如何使用键盘激活按钮?到目前为止,我发现此代码是用于标签而非按钮的

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

0 个答案:

没有答案