Search code examples
javascriptonkeyup

prevent the regular tab-key function onkeyup


I have about 20 small dropdowns in row. Each of those have two javascript functions.

  • onchange: call an ajax function for saving the value
  • onkeyup: jump to the next dropdown and open it

Now if the user press tab, the next dropdown will be omitted. This is why I want to prevent the regular tab-key function. How to do this?


Solution

  • you can call such a method :

    function keyHandler(e) {
        var TABKEY = 9;
        if(e.keyCode == TABKEY) {
            if(e.preventDefault) {
                e.preventDefault();
            }
            return false;
        }
    }