Replace keyCode 13 with 9

Posted on 2014-02-05
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?
Question by:djpriceAtl
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
LVL 58

Expert Comment

ID: 39836405

Author Comment

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.
LVL 58

Expert Comment

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

Accepted Solution

Gary earned 500 total points
ID: 39836517
How does this work for you
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) {

Open in new window


Author Closing Comment

ID: 39836871
Excellent - thank you!

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Accordion won't close correctly 5 14
Two decimal 5 29
Prevent certain words from being typed in a form 6 31
How do I split a variable to newline 2 19
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

726 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