Handle Enter key like the Tab key

by jrose 5/7/2010 9:57:00 AM

To allow ease of use for users that aren't accustomed to using the Tab key to switch between HTML elements and would prefer to use the Enter instead, simply add a OnKeyDown event handler to the element that changes a key code of 13 [Enter's value] to 9 [Tab's value].

 

For example:

<input type="text" onkeydown="if (event.keyCode==13) {event.keyCode=9; return event.keyCode }" id="text1">

<input type="text" id="text2">

 

After entering text into the text1 element, the user is allowed to press Enter [or Tab] to navigate to the text2 element.

Tags: , , , , , ,

JavaScript

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign in