[thelist] hack to use Enter instead of Tab on forms

sbeam sbeam at onsetcorps.net
Wed Feb 2 21:27:10 CST 2005

A client of mine says she likes to use the number pad on her keyboard to 
enter sets of numbers in a retail pricing app we've built. So she'd 
like to be able to use that little Enter key there instead of the Tab 
to cycle through form fields (These forms typically have hundreds of 
fields across multiple screens, so from a usability perspective, I can 
see the point).

Somebody else must have had this request. I'm thinking something along 
the lines of 
// sort-of-fake JS code off the top of my head, be kind:
fieldCollection = document.getElementsByTagName('INPUT');
for (i=0; i<fieldCollection.length; i++) {
   fieldCollection[i].onKeyPress = new function (e) {
      if (e.keyCode == 'Enter') { // whatever that code is
         if (!isIE) e.stopPropagation();
         else e.cancelBubble = true;

should _theoretically_ work... but as we all know Enter is used to 
submit the form by default, and I have a hunch that some IE5/Mac bug is 
going to ruin my day. 

So is it a bad idea? We need the 'modern' browsers to work. Should I 
tell her its possible or say 'no way' and save a headache?



# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/

More information about the thelist mailing list