0

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?

user2881493
  • 37
  • 1
  • 5

2 Answers2

3

you can call such a method :

function keyHandler(e) {
    var TABKEY = 9;
    if(e.keyCode == TABKEY) {
        if(e.preventDefault) {
            e.preventDefault();
        }
        return false;
    }
}
murtaza.webdev
  • 3,523
  • 4
  • 22
  • 32
2

this code might help you

$("your-selector").on('keyup', function(e) { 
    if (e.keyCode == 9) { // <- here confirm that tab is pressed.
       e.preventDefault(); // <- Prevent defaul functionality of tab.
       // your code if tab pressed.
    }
    // code if its not a tab key.
});
Sohil Desai
  • 2,940
  • 5
  • 23
  • 35