[Solved] javascript keydown not working in chrome and firefox [closed]


I don’t think you should use onkeydown on the table rows.
Keydown on rows only works if you have an input element inside them. otherwise they can’t be focused.

Don’t know if that is feasible in your case, but you could try it like this. if for whatever reason you don’t want to use jQuery you’ll have to modify it a bit for browsers which don’t support querySelector:

document.body.addEventListener('keydown',function(ev){
    var trs = document.querySelector('.s');
    if(ev.keyCode == 38 && trs.previousSibling){
        trs.className="";
        trs.previousSibling.className="s";
    }else if(ev.keyCode == 40 && trs.nextSibling){
        trs.className="";
        trs.nextSibling.className="s";
    }
})

http://jsfiddle.net/FvgaE/

3

solved javascript keydown not working in chrome and firefox [closed]