wathing for ALt key in keydown event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GS

    wathing for ALt key in keydown event

    apparently the following in keyDown event fails to capture the alternate
    key down

    Private Sub cbAddressBar_Ke yDown(ByVal sender As System.Object, ByVal e As
    System.Windows. Forms.KeyEventA rgs) Handles CBAdressBar.Key Down
    If e.KeyCode = Keys.Alt Then ' does not work!!
    bAltKeyDn = True
    Return
    End If

    If e.KeyCode = Keys.ControlKey Then '' this works for control
    key down
    ' some process logic for control key action...
    End If

    ' other processing. action..

    End Sub

    What should I do instead?


  • Herfried K. Wagner [MVP]

    #2
    Re: wathing for ALt key in keydown event

    "GS" <gsmsnews.micro soft.comGS@msne ws.Nomail.comsc hrieb:
    apparently the following in keyDown event fails to capture the alternate
    key down
    >
    Private Sub cbAddressBar_Ke yDown(ByVal sender As System.Object, ByVal e As
    System.Windows. Forms.KeyEventA rgs) Handles CBAdressBar.Key Down
    If e.KeyCode = Keys.Alt Then ' does not work!!
    bAltKeyDn = True
    Return
    'If CBool(Control.M odifierKeys And Keys.Alt) Then...'.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • kimiraikkonen

      #3
      Re: wathing for ALt key in keydown event

      On Mar 17, 8:10 pm, "GS" <gsmsnews.micro soft.co...@msne ws.Nomail.com>
      wrote:
      apparently  the following in keyDown event fails to capture the alternate
      key down
      >
      Private Sub cbAddressBar_Ke yDown(ByVal sender As System.Object, ByVal e As
      System.Windows. Forms.KeyEventA rgs) Handles CBAdressBar.Key Down
              If e.KeyCode = Keys.Alt Then    ' does not work!!
                  bAltKeyDn = True
                  Return
              End If
      >
              If e.KeyCode = Keys.ControlKey Then     '' this works for control
      key down
                  ' some process logic for control key  action...
              End If
      >
              ' other processing. action..
      >
      End Sub
      >
      What should I do instead?
      Try:
      ' ' You can also leave blank the initial value
      Dim bAltKeyDn As Boolean = False
      Private Sub cbAddressBar_Ke yDown(ByVal sender As System.Object, ByVal
      e As
      System.Windows. Forms.KeyEventA rgs) Handles CBAdressBar.Key Down
      If e.KeyCode = Keys.Alt Then ' does not work!!
      bAltKeyDn = True
      End If

      and try to set keypreview property of your form to true.


      Comment

      • GS

        #4
        Re: wathing for ALt key in keydown event

        thank you. much appreciated
        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
        news:%23M4aRKFi IHA.4844@TK2MSF TNGP06.phx.gbl. ..
        "GS" <gsmsnews.micro soft.comGS@msne ws.Nomail.comsc hrieb:
        apparently the following in keyDown event fails to capture the
        alternate
        key down

        Private Sub cbAddressBar_Ke yDown(ByVal sender As System.Object, ByVal e
        As
        System.Windows. Forms.KeyEventA rgs) Handles CBAdressBar.Key Down
        If e.KeyCode = Keys.Alt Then ' does not work!!
        bAltKeyDn = True
        Return
        >
        'If CBool(Control.M odifierKeys And Keys.Alt) Then...'.
        >
        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
        >

        Comment

        Working...