Shortcut Keys

How can a make a shortcut key combination ( ie ctrl+shift+q) open a form


Answer this question

Shortcut Keys

  • Sice

    Here's an example of a Keypress event handler

     

     

    Private Sub Combinedlv1AndTvc_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _

                    Handles lv1.KeyPress, Tvc.KeyPress, Me.KeyPress

     

            ' Form1.lv1_KeyPress - Called by user Keypresses

            ' This is a dispatcher which makes call when Keystrokes of interest are made when either Lv1, Tvc or Form1

            ' has focus.

            Const ControlA As Char = Chr(1)

            Const ControlC As Char = Chr(3)

            Const ControlV As Char = Chr(22)

            Const ControlX As Char = Chr(24)

            Const F1 As Char = Chr(Keys.F1)

     

            Dim TVFocus As Boolean = Tvc.Focused

            Dim LVFocus As Boolean = lv1.Focused

     

            Select Case e.KeyChar

                Case ControlA

     

                  'Process Stuff                        

     

                Case ControlC        ' Copy

     

                  'Process Stuff                        

                Case ControlV        ' Paste

     

                  'Process Stuff                        

     

     

                Case "S", "s"

                    Dim ab As New KNProperties(DefaultLV)

                Case F1

                    DisplayHelp(Me, 1)

            End Select

     

        End Sub



  • JustAnAverageJoe

    Im looking for something to come up only when the app is running...



  • eduard.gruber

    Could you clarify what you just said

  • mcazalet

    Was the tutorial here not what you were looking for

  • momark

    Assuming you mean at runtime... just for note though... traditionally a shortcut key is a keystroke that works inside of the app... like alt-f bringing up the file menu... what you are looking for is a keystroke that would be able to trigger an event regardless of what app is running... for that you are looking more into the realm of setting up a hotkey.

    Take a look at this CodeProject article for some code and an explanation on how to do it.



  • Shortcut Keys