Disable space for WebBrowser

When the user focuses on managing the web browser and press a key Space, the web browser will scroll down. How to disable this event?

+5
source share
3 answers

Finally, this javascript code solves my problem:

onkeypress='if(event.keyCode=13) return false;'

because a false return for spaceKey prevents the web browser from scrolling!

0
source

I think you need to interrupt the keyboard event from your application and cancel the event information sent to your control, make sure that you do not cancel the SpaceKey all the time, as would be necessary in other places.

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx

, !

0

use the event _PreviewKeyDown
example:

If e.KeyCode = Keys.Space Then
    WebBrowser1.Navigate("javascript:scroll(0,0)")

End If


;)

0
source

All Articles