Resolved How to: (Control.ModifierKeys And Keys.Control)

vmars316

Active member
Joined
Aug 24, 2020
Messages
39
Programming Experience
Beginner
Hello & Thanks ;

win 10 vs 2019 vb.net .vb WebBrowser app .
I am trying to detect Ctrl key pressed .
For some sites , in this case pbskids.org ,
I am unable to make a click on image-link work .
But in 'Sub TimerStatus_Tick' hover over link , shows in StatusLbl control .
So what I want to do is when StatusLbl shows a link , if I click on Ctrl-key ,
then navigate to that site .
Pls , what am I doing wrong in code below;
Thanks for your Help...
VB.NET:
    Private Sub WebBrowser1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If (Control.ModifierKeys And Keys.Control) = Keys.Control Then
            '                    (CType(sender, Control)).Hide()
            '            If StatusLbl.Text.Length > 6 Then
            MsgBox("WebBrowser1 =  " & StatusLbl.Text)
            WebBrowser1.Navigate(StatusLbl.Text)
            '            End If
        End If
    End Sub
 
I found a solution , that takes care of problem ;
VB.NET:
 Private Sub WebBrowser1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
     If (Control.ModifierKeys And Keys.Control) = Keys.Control Then
         MessageBox.Show("Ctrl is pressed!")
     End If
 End Sub
Thanks
 
Back
Top