How to disable tab key globally except for all forms in a page with JavaScript?
<p>I'm making a single page app that is launching next week, for a pretty huge client, and going live for a pretty big event and well, there's still a ton to finish before then.</p>

<p>There's 100+ 'pages' which are all loaded within a single 700px x 600px window, and I had learned not long ago you could tab through the page/sections, which in-turn would break the app because it would bring focus to hidden off-screen elements, so for this reason, I disabled the tab key for the entire app.</p>

<p>But now there are a couple places where we have a form with a handful of input fields which you are not able to tab through as you fill in the form. It's a pain in the ass.</p>

<p>I need to make it so you can tab through the form fields, but only the form fields. I have the tabindex attribute set for the form, and have tried to make inputs tab enabled but was not able to make it work without causing the app to jump to hidden sections.</p>

<p>Here's the function I need to change so it will disable tab key except from input to input fields in a form.</p>

<pre><code>window.onkeydown = function(e) {
    if (e.keyCode === tab) {
        return false;
    }
}
</code></pre>

<p>I tried to do this, which obv didnt work lol</p>

<pre><code>$('input').keydown(function(e) {
    if (e.keyCode === tab) {
        return true;
    }
});
</code></pre>

<p>Thanks :)</p>
