Mathachew / jquery-autotab

A jQuery plugin that provides auto tabbing and filtering on text fields in a form
http://autotab.mathachew.com/
366 stars 98 forks source link

Option to turn off autotab when TAB key pressed #90

Closed gunnx closed 8 years ago

gunnx commented 8 years ago

For those people who use keyboard as primary input device, they would normally press TAB to advance to next field, with autotab in action this can confuse things, so could add option to check for TAB key presses which then turn off autotabbing.

Mathachew commented 8 years ago

@gunnx Thanks for the input. Since 1.2, Autotab has been doing this very thing. It will ignore the tab key (once) for 800 milliseconds so that it doesn't tab two elements over. If you're seeing a different behavior, can you give me a little more info to work with?

gunnx commented 8 years ago

@Mathachew Hi Matthew, not that's fine, its more a different behaviour, this option would disable autotabbing permanently as soon as TAB key is pressed.

Mathachew commented 8 years ago

You should be able to do this without changing anything in Autotab with something like this (untested):

$('.number').on('keydown', function (e) {
    var keyCode = e.which || e.charCode;

    // When TAB is pressed, turn off Autotab
    if (keyCode == 9) $.autotab.remove();
});

By not passing a value to remove, it would turn off Autotab on all fields. See here for more info.

gunnx commented 8 years ago

@Mathachew thanks, yes that could do the job. Happy for you to close this.

Mathachew commented 8 years ago

Glad to help!