JQuery Disable keyboard shortcut on focus

Ok so i have set up some keyboard shortcuts on my photoblog for navigation. I would like to disable these shortcuts when someone is using the comment section. Here is what i have:

var doFocusArrow  = 1;

    $("input").focus(function () {
       doFocusArrow = 2; 
    });
	
	    $("input").blur(function () {
       doFocusArrow = 1;
    });


document.onkeydown=function(e) {
    if(e.which == 37 && doFocusArrow == 1) {
        window.location = "http://www.blursurfing.com/index.php?showimage=<IMAGE_PREVIOUS_ID>";
         return false;
    }
	    if(e.which == 39 && doFocusArrow == 1) {

        window.location = "http://www.blursurfing.com/index.php?showimage=<IMAGE_NEXT_ID>";
         return false;
    }
	
		    if(e.which == 82 && doFocusArrow == 1) {
        window.location = "http://www.blursurfing.com/index.php?showimage=<IMAGE_RANDOM>";
         return false;
    }
	
};

The keyboard shortcuts work, but they do not disable when someone enters the form input fields.

What am i doing wrong?

cheers

    
$("input").focus(function () {
       doFocusArrow = 2; 
    });
	
$("input").blur(function () {
       doFocusArrow = 1;
    });


on second thought do these even need to be a function?