Detect the Enter key in an text input field
<p>I'm trying to do a function if enter is pressed while on specific input.</p>

<p>What I'm I doing wrong?</p>

<pre><code>$(document).keyup(function (e) {
    if ($(".input1").is(":focus") &amp;&amp; (e.keyCode == 13)) {
        // Do something
    }
    });
</code></pre>

<p>Is there a better way of doing this which would say, if enter pressed on .input1 do function?</p>

<p>Thanks alot</p>
