Simba
Simba

Reputation: 41

IE9 control keyboard buttons

I am trying to make form submit with TAB button.

It is working on FF, IE8, but on IE9 i cannot stop default action.

I found the answer here: How do I convert Enter to Tab (with focus change) in IE9? It worked in IE8

But i cannot implement it.

Could somebody explain what "Fix" for ie9 i should add my script to work.

Thank you

function checkcode(e) {
    var keycode;
    if(!e)
        e = window.event;
    if(e.keyCode)
       keycode = e.keyCode;
    else
       keycode = e.charCode; 
    if(keycode == 9 || keycode == 13) {
        e.preventDefault();            //Problem is here
        alert(keycode);
        return false;
    } else return true;
}

Upvotes: 0

Views: 624

Answers (1)

Simba
Simba

Reputation: 41

Problem was that in IE onkeypress does not return keycodes for ctrl, shift or tab, onkeydown done the trick.

Upvotes: 1

Related Questions