Perform a tab with js

The base for the keydown event handling function goes like this:


body.onkeydown = function (evt) {
    var allowDefault = true;
    evt = evt || event;

    if (evt.keyCode === 9) {
        // tab was pressed
    }
    return allowDefault;
};

The reason for the allowDefault variable is so that you can decide whether if you want the web browser to accept the key or not, depending on the needs of your particular situation.