同时按下多个键

时间:2013-10-25 14:44:33

标签: vb.net visual-studio keyboard-shortcuts

如何在同时按下多个键时发送字符串/消息框? 我已尝试And以及Andalso,但结果是只需要第一个键来弹出该msgbox。

Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _
                                       ByVal keyData As System.Windows.Forms.Keys) _
                                       As Boolean
        If msg.WParam.ToInt32() = CInt(Keys.ShiftKey) AndAlso CInt(Keys.A) Then
            MsgBox("Testing")
            Return True
        End If

        Return MyBase.ProcessCmdKey(msg, keyData)
End Function

1 个答案:

答案 0 :(得分:2)

您可以这样做:

Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _
                                   ByVal keyData As System.Windows.Forms.Keys) _
                                   As Boolean
    If keyData = (Keys.Shift Or Keys.A) Then
        MessageBox.Show("Shift-A")
        Return True
    End If

    Return MyBase.ProcessCmdKey(msg, keyData)
End Function

注意这个