'How to set the Style of a HtmlElement at the Mouse position when a Key is pressed

I have a TABLE Element in the current Document of a WebBrowser control.
I want to be able to color a Cell when my cursor is on it, when I press the A Key

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        htmlDocument1 = WebBrowser1.Document
        AddHandler htmlDocument1.MouseOver, AddressOf Me.gettd
End Sub

Public Sub gettd(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs)
    Dim theElementCollection As HtmlElementCollection
    theElementCollection = WebBrowser1.Document.GetElementsByTagName("td")
    For Each curElement As HtmlElement In theElementCollection
        e.ToElement.Style = "background-color: orange;"
    Next
End Sub

Setting KeyPreview = True:

Public Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles Me.KeyDown
   If e.KeyCode = Keys.A Then
   ...
   end if
End Sub

How else can I achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source