Key press

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

    Key press

    Hello.

    In Event key_press I write
    If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then

    Asci 127 is key DELET.

    But it doesn't work, when I get other Ascii It's ok.

    And When I press CTRL+BACKSPACE with ascii 127 it's ok. CTRL+BACKSPACE = DEL, but with del it doesn't work.

    Can anybody write me where is problem?

    Thanks.


  • Ken Tucker [MVP]

    #2
    Re: Key press

    Hi,

    Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown
    If e.KeyCode = Keys.Delete Then
    MessageBox.Show ("Delete pressed")
    End If
    End Sub

    Ken
    --------------
    "Rado" <r-soft@szm.sk> wrote in message news:uuVLvBIMEH A.1308@TK2MSFTN GP10.phx.gbl...
    Hello.

    In Event key_press I write
    If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then

    Asci 127 is key DELET.

    But it doesn't work, when I get other Ascii It's ok.

    And When I press CTRL+BACKSPACE with ascii 127 it's ok. CTRL+BACKSPACE = DEL, but with del it doesn't work.

    Can anybody write me where is problem?

    Thanks.


    Comment

    • Ken Tucker [MVP]

      #3
      Re: Key press

      Hi,

      Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown
      If e.KeyCode = Keys.Delete Then
      MessageBox.Show ("Delete pressed")
      End If
      End Sub

      Ken
      --------------
      "Rado" <r-soft@szm.sk> wrote in message news:uuVLvBIMEH A.1308@TK2MSFTN GP10.phx.gbl...
      Hello.

      In Event key_press I write
      If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then

      Asci 127 is key DELET.

      But it doesn't work, when I get other Ascii It's ok.

      And When I press CTRL+BACKSPACE with ascii 127 it's ok. CTRL+BACKSPACE = DEL, but with del it doesn't work.

      Can anybody write me where is problem?

      Thanks.


      Comment

      • Armin Zingler

        #4
        Re: Key press

        "Rado" <r-soft@szm.sk> schrieb[color=blue]
        >
        > In Event key_press I write
        > If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then
        >
        > Asci 127 is key DELET.
        >
        > But it doesn't work, when I get other Ascii It's ok.
        >
        > And When I press CTRL+BACKSPACE with ascii 127 it's ok.
        > CTRL+BACKSPACE = DEL, but with del it doesn't work.
        >
        > Can anybody write me where is problem?[/color]

        First, your keyboard (and it's driver) produces "virtual keycodes". Whenever
        a key is held down or released, the keydown or keyup events are raised. In
        the event handlers, e.keycode contains the virtual keycode. (Almost) all
        keys create this message and event.

        Second, some of the keys or a combination of them are translated to input
        chars afterwards. Others don't, like the function keys. If you press delete,
        no input char is created. Use the keydown event to handle the Delete key.


        --
        Armin

        How to quote and why:





        Comment

        • Armin Zingler

          #5
          Re: Key press

          "Rado" <r-soft@szm.sk> schrieb[color=blue]
          >
          > In Event key_press I write
          > If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then
          >
          > Asci 127 is key DELET.
          >
          > But it doesn't work, when I get other Ascii It's ok.
          >
          > And When I press CTRL+BACKSPACE with ascii 127 it's ok.
          > CTRL+BACKSPACE = DEL, but with del it doesn't work.
          >
          > Can anybody write me where is problem?[/color]

          First, your keyboard (and it's driver) produces "virtual keycodes". Whenever
          a key is held down or released, the keydown or keyup events are raised. In
          the event handlers, e.keycode contains the virtual keycode. (Almost) all
          keys create this message and event.

          Second, some of the keys or a combination of them are translated to input
          chars afterwards. Others don't, like the function keys. If you press delete,
          no input char is created. Use the keydown event to handle the Delete key.


          --
          Armin

          How to quote and why:





          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Key press

            * "Rado" <r-soft@szm.sk> scripsit:[color=blue]
            > In Event key_press I write
            >
            > If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then
            >
            > Asci 127 is  key DELET.
            >
            > But it doesn't work, when I get other Ascii It's ok.
            >
            > And When I press CTRL+BACKSPACE with ascii 127 it's ok.  CTRL+BACKSPACE = DEL, but with del it doesn't work.[/color]

            Compare 'e.KeyChar' to one of the 'Keys.*' constants.

            --
            Herfried K. Wagner [MVP]
            <URL:http://dotnet.mvps.org/>

            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Key press

              * "Rado" <r-soft@szm.sk> scripsit:[color=blue]
              > In Event key_press I write
              >
              > If e.KeyChar = Microsoft.Visua lBasic.Chr(127) Then
              >
              > Asci 127 is  key DELET.
              >
              > But it doesn't work, when I get other Ascii It's ok.
              >
              > And When I press CTRL+BACKSPACE with ascii 127 it's ok.  CTRL+BACKSPACE = DEL, but with del it doesn't work.[/color]

              Compare 'e.KeyChar' to one of the 'Keys.*' constants.

              --
              Herfried K. Wagner [MVP]
              <URL:http://dotnet.mvps.org/>

              Comment

              Working...