e.which ENTER key enabled only if input field focus
<p>I am using a e.which of jquery for running a function on press of ENTER, but I want this function to be called only if the particular input field is focused (where the cursor is blinking).</p>

<p>My current jquery function.</p>

<pre><code>$(document).keyup(function(e) {
    if (e.which == 13) {
        var page = $("#userpage").val();

        if(page &gt; 0) {
            $("#search").click();
        } else {
            $('.save').click();
        }
    }
});
</code></pre>

<p>I want that <strong>$("#search").click();</strong> to be called only if the <strong>#search_text</strong> is focused or has some input, because I have few more input fields and users tend to press enter, and on Enter this function is called.</p>

<p>Thank You.</p>
