Replace keyCode 13 with 9

This worked in IE9 but no longer works in IE11:
function remapEnter()
{
   if(window.event.keyCode == 13) //trap enter
   {
      if(document.activeElement.type!='textarea')  //if not textarea type
      {
         // convert to Tab key
         window.event.keyCode = 9;
         return window.event.keyCode; 
      }
   }
}

Open in new window

I want to allow users to press 'Enter' to go to the next data entry field.  Does anyone know how to get this working?
djpriceAtlAsked:
Who is Participating?
 
GaryConnect With a Mentor Commented:
How does this work for you
http://jsfiddle.net/evcB2/2/
Doesn't account for disabled/hidden fields

var i=0;
var els=myform.getElementsByTagName('input').length
document.onkeydown = function(e) {
    e = e || window.event;
    if (e.keyCode == 13) {
        i++;
        i>els-1?i=0:i=i;
        document.myform[i].focus();
    }
};

Open in new window

0
 
GaryCommented:
0
 
djpriceAtlAuthor Commented:
Thanks but that is a jquery solution, I was looking more for javascript.  However, I see what you are saying that I need to change focus and not the keycode.
0
 
GaryCommented:
jQuery is javascript.  I'll try and put something together shortly.
0
 
djpriceAtlAuthor Commented:
Excellent - thank you!
0
All Courses

From novice to tech pro — start learning today.