0

Im not trying to capture if a user clicked enter or not. What I am trying to do is send an enter key in javascript.

I have an asp.net textbox:

<asp:TextBox id="myBox" runat="server" OnChange="SendEnter" />

On any key press in this text box I want it to call a client side function called "SendEnter".

In send enter I want to send the enter keystroke (this is not to submit a form but to fire the server side OnChanged event of the asp.net textbox).

Can I do something like:

function SendEnter() {
 var theKey = 13; //enter key?
 document.trigger(13);  //not sure if this even exists
}
oJM86o
  • 2,108
  • 8
  • 43
  • 71

1 Answers1

0

You may try to simulate the event:

Is it possible to simulate key press events programmatically?

The important thing is to pay attention to the keycode that represents the Enter:

press.which = 13;
Community
  • 1
  • 1
pdjota
  • 3,163
  • 2
  • 23
  • 33