How to stop keyboard functions from firing when the letters are typed in a form?
<p>I have this script which fires scrolling to next/prev when "N" and "P" keys on keyboard are pressed. My question is how to stop this from firing when the user type these letters normally in any form (such as search field, login field, and so on.) because when I press n e.g. John in a form it does not write N instead it fires the scroll function. How to fix that behaviour?</p>

<p>My code is below:</p>

<pre><code>$(document).keydown(function (evt) {
    if (evt.keyCode == 78) {
        evt.preventDefault();
        scrollToNew();
    } else if (evt.keyCode == 80) {
        evt.preventDefault();
        scrollToLast();
    }
});
</code></pre>

<p>Thank you.</p>
