I am trying to create keypress handler that will execute a line of code when Tab, Space, or Enter key is pressed or passed by the scanner gun while the control is in focus. I got it to work with space and enter key but with tab key, the cursor will just jump to the next tab stop without executing the code.
Anyone know how to make tab key work?

Private Sub Button2_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Button2.KeyPress
        Dim keyChar As Char
        keyChar = e.KeyChar

        If AscW(keyChar) = 9 Or AscW(keyChar) = 32 Or keyChar = "\t" Or keyChar = "\r" Then
            Button2.PerformClick()
        Else
            e.Handled = True
        End If

    End Sub

Thanks in advance

If anyone to have the same problem here is the solution for it using keyboard overrides.
Add the following code to your form

Protected Overrides Function ProcessTabKey(forward As Boolean) As Boolean
        MyBase.ProcessTabKey(forward)
    End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.