VB.NET 怎样识别用户按下的 Shift 按键??[2]
发布网友
发布时间:2024-10-02 23:36
我来回答
共2个回答
热心网友
时间:2024-10-19 04:07
需要用api实现 给你代码吧 咋不给点分啊?
Public Class Form1
Private Const KeysM = &H8000
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Me.Text = e.KeyValue
If e.KeyValue = Keys.ShiftKey And GetAsyncKeyState(160) And KeysM Then
MsgBox("你按的是左SHIFT")
ElseIf e.KeyValue = Keys.ShiftKey And GetAsyncKeyState(161) And KeysM Then
MsgBox("你按的是右SHIFT")
End If
End Sub
End Class
热心网友
时间:2024-10-19 04:08
左SHIFT的枚举值lshiftkey 右shift的枚举值rshiftkey