UnervDeveloper Posted September 30, 2009 Share Posted September 30, 2009 Hello, I would like to know how to Simulate a Click on a Button by Pressing Enter on the Keyboard In VB.Net 2008. I am working on a web browser, and would like to know how to do this. Thank You, UnervDeveloper Link to comment Share on other sites More sharing options...
0 Rohdekill Posted September 30, 2009 Share Posted September 30, 2009 I could be wrong, but by setting focus on the button, enter key will trigger the action for it Link to comment Share on other sites More sharing options...
0 svnO.o Posted October 5, 2009 Share Posted October 5, 2009 What part of the form will be focused when the user presses enter? Whatever it is, simply add an event handler for the KeyDown event. Example: Private Sub txtAddress_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtAddress.KeyDown If e.KeyCode = Keys.Enter Then e.SuppressKeyPress = True btnGo_Click(sender, e) End If End Sub In this case if you hit enter on the text box identified as "txtAddress" (address box) it will prevent the enter key from being registered and showing up in the text box. It would then call the function used by "btnGo" (button) the same as if a person were to click on it. Link to comment Share on other sites More sharing options...
Question
UnervDeveloper
Hello,
I would like to know how to Simulate a Click on a Button by Pressing Enter on the Keyboard In VB.Net 2008. I am working on a web browser, and would like to know how to do this.
Thank You,
UnervDeveloper
Link to comment
Share on other sites
2 answers to this question
Recommended Posts