jQuery on() method is firing more than one time <p>I made some jQuery code for preventing users from typing chars but only numbers:</p> <pre><code> $("div").on("keydown", ":text", checkKey); function checkKey(e) { var n = e.keyCode; if (n == 13) { $(this).closest("form").submit(); console.log('enter'); } else if (e.shiftKey || e.ctrlKey || e.altKey) { e.preventDefault(); } else { if (!((n == 8) || (n == 46) || (n == 9) || (n &gt;= 35 &amp;&amp; n &lt;= 40) || (n &gt;= 48 &amp;&amp; n &lt;= 57) || (n &gt;= 96 &amp;&amp; n &lt;= 105)) ) { e.preventDefault(); console.log('ok'); } } } </code></pre> <p>end in html:</p> <pre><code> &lt;div&gt; &lt;input type="text" id="test" /&gt; &lt;/div&gt; </code></pre> <p>but whenever I type something, it seems it's being fired three times for example for one pressing enter I get three 'enter' in console and for numbers I get three 'ok', why is that? I also replaced it with delegate and live, live worked fine but delegate also was fired three times. thanks. </p>