I don't know if that is possible as when you are in a text box, the behavior on hitting return may vary from one text field to another. For a textarea it will go to the next line and if on the last line it will expand to another new line. If a plain text field, hitting enter may activate the default submit button. You can use things like onclick but I don't think the enter key is usable. Someone correct me if I'm wrong. --le ----- Original Message ----- From: "Alex Hall" <mehgcap@xxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Friday, April 17, 2009 11:21 PM Subject: E: quick js question about calling functions I would like to call the function when the enter key is pressed in an input box (input type="text"). I know about how to do it with buttons and links, but not with textboxes; it should not be a clickable object; I just want the user to be able to hit enter and have the function called. Thanks. Have a great day, Alex > ----- Original Message ----- >From: "Adrian Beech" <a.beech@xxxxxxxxxxxxxx >To: <programmingblind@xxxxxxxxxxxxx >Date sent: Sat, 18 Apr 2009 11:07:01 +1000 >Subject: RE: quick js question about calling functions >G'day Alex, >Yup it certainly can be done. For clickable objects such as buttons the tag >which I use goes along the lines of <input type="button" value="Click Me" >onclick="myFunction()"/> and with hyperlinks I use <a >href="javascript:myFunction()">Click Me</a>. It's also generally good >practice to put the functions in a separate .js file and add a <script >type="text/javascript" src="my_functions.js"></script> within the head >section of your page. >HTH. >Cheers. >AB >-----Original Message----- >From: programmingblind-bounce@xxxxxxxxxxxxx >[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall >Sent: Friday, 17 April 2009 11:37 PM >To: programmingblind@xxxxxxxxxxxxx >Subject: quick js question about calling functions >Hi all, >Just a quick question: in a webpage, I have a textbox. I would >like the user to be able to hit the ENTER key in this box and >call a function, instead of needing to click a button. The page >is a simple game meant to be played offline, so the page should >not go anywhere or reload itself. Basically, I want the enter >key inside a textbox to take the place of a button. Can this be >done? >Have a great day, >Alex >__________ >View the list's information and change your settings at >//www.freelists.org/list/programmingblind >__________ NOD32 4017 (20090417) Information __________ >This message was checked by NOD32 antivirus system. >http://www.eset.com >__________ >View the list's information and change your settings at >//www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind