Catch KeyPress only once.
Posted on 2013-01-19
I'm creating a multitabbed webbrowser, and want to get better control, when tabbing through the tabs.
For that i have created a Sub to catch the Control + Tab keyboard event, but it seems that I'm catching the keypresses continuously, instead of once.
The code looks like this:
Private Sub Browser_PreviewKeyDown(sender As Object, e As System.Windows.Forms.PreviewKeyDownEventArgs)
If (e.KeyCode = Keys.Tab AndAlso e.Modifiers = Keys.Control) Then
' Control + Tab pressed
Dim tnt = ActiveTabPage
tnt = tnt + 1
If tnt = 10 Then tnt = 0
TabControl1.SelectedIndex = tnt
I would expect that I will need to catch the keyup event as well, but I haven't been succesfull in implementing it with the code above.
Suggestions would be very much appreciated.