Link to home
Start Free TrialLog in
Avatar of piattnd
piattnd

asked on

How to make an Input field recognize the enter keystroke

I've got an HTA that has 1 input box and 8 read only return boxes.  I want the 1 input box to submit the user's entry on the enter keystroke.  I know the input box has to have the onKeyDown(callsub), but what does the sub do?
Avatar of piattnd
piattnd

ASKER

So an update on this, I got it so it recognizes the enter keystroke, now how to I tell the SUB to click the submit button if the keystroke = enter?
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of piattnd

ASKER

Thanks much, I actually had hit up a friend who helped me understand what was going on.  I appreciate the response (yours was what I was looking for)!
Hi, you can add this to you <body> tag in the HTML section:
<body onkeypress='vbs:Default_Buttons'>

and then add this in your <script> section:
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_install.Click
      End If
End Sub


where you can change btn_install.Click to the name of the OK button control.

Regards,

Rob.
Hmm, that grade simply seems inappropriate. The answer was technically sound. So I "lost" 500pts for no reason. Perhaps you should read:
https://www.experts-exchange.com/help.jsp#hi504
Avatar of piattnd

ASKER

My fault hielo, I gave you a B because I had already found solution prior to your posting.... :-/
Avatar of piattnd

ASKER

Rob,

I'll give that a shot on the next HTA I use.  I was actually curious if there was a way to just "push" the button through code, which appears to be what you suggested.