Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Replace keyCode 13 with 9

Posted on 2014-02-05
5
Medium Priority
?
2,429 Views
Last Modified: 2014-02-05
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?
0
Comment
Question by:djpriceAtl
[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
  • 3
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39836405
0
 

Author Comment

by:djpriceAtl
ID: 39836437
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
 
LVL 58

Expert Comment

by:Gary
ID: 39836483
jQuery is javascript.  I'll try and put something together shortly.
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39836517
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
 

Author Closing Comment

by:djpriceAtl
ID: 39836871
Excellent - thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

609 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