?
Solved

How to make an Input field recognize the enter keystroke

Posted on 2008-10-31
7
Medium Priority
?
759 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:piattnd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 12

Author Comment

by:piattnd
ID: 22853688
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?
0
 
LVL 82

Accepted Solution

by:
hielo earned 1500 total points
ID: 22854553
>> click the submit button if the keystroke = enter
are you trying to submit the form?
If yes, then make sure you give the form an id:
<form id="theForm">
 
and when you detect the Enter you then execute:
document.getElementById("theForm").submit()
 
If you are NOT trying to submit the form, but instead are trying to execute some onclick function on the button:
<input type="button" onclick="foo()">
 
then simply call the function directly when you detect the enter key

Open in new window

0
 
LVL 12

Author Closing Comment

by:piattnd
ID: 31512173
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)!
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 65

Expert Comment

by:RobSampson
ID: 22854716
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.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22855576
Hmm, that grade simply seems inappropriate. The answer was technically sound. So I "lost" 500pts for no reason. Perhaps you should read:
http://www.experts-exchange.com/help.jsp#hi504
0
 
LVL 12

Author Comment

by:piattnd
ID: 22872520
My fault hielo, I gave you a B because I had already found solution prior to your posting.... :-/
0
 
LVL 12

Author Comment

by:piattnd
ID: 22872566
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.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question