简体   繁体   中英

keyboard input with ctrl,alt, shift + key

I am coding some keyboard inputs to my code, but i'm having trouble figuring out how to get the keys that require a ctrl , alt or shift input as well. I tried this but this just make the key work as soon as i press the alt key. I am trying to use the + button that is not on the numpad.

Case Keys.ShiftKey And Keys.Oemplus
            BTB_plus.PerformClick()

And Using keys.Shift does nothing at all

Also, if someone has a list of which key has what name in VB.NET, it would be appreciated. (or good tutorials on this subject)

Would prefer if someone could post the code for a select case statement, thx

If you want to use case statement I would then perform this:

Dim bHandled As Boolean = False
    Select Case e.Modifiers
        Case Keys.Control
            If e.KeyCode = Keys.Oemplus Then
                MsgBox("KeyPress CTRL + OEMPLUS")
                e.Handled = True
            End If

            If e.KeyCode = Keys.A Then
                MsgBox("KeyPress CTRL + A")
                e.Handled = True
            End If


        Case Keys.Shift
            If e.KeyCode = Keys.Oemplus Then
                MsgBox("KeyPress Shift + OEMPLUS")
                e.Handled = True
            End If

            If e.KeyCode = Keys.A Then
                MsgBox("KeyPress Shift + A")
                e.Handled = True
            End If

    End Select

This should get you there :)

If e.KeyCode = Keys.Oemplus And e.Modifiers = Keys.Control Then
    MsgBox("KeyPress CTRL + OEMPLUS")
    e.Handled = True
End If

http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM