Search code examples
jquerykeypress

jquery keypress issue


I have this code for redirecting when a key is pressed:

$('body').bind('keyup', function(event) {
    if(event.keyCode==66){ window.location = "page.php"; }
    });

Ok but, how can i make it not applicable if the user has an input field in focus on the page?


Solution

  • Try this may be.

    if ( $("*:focus").is("textarea, input") ) return;