Is it possible to trigger a key event only outside a form element? Background: I have a code that loads the next page when the right key is pressed. But I don't want to trigger that event if somebody is using that key in a form element.current code:\[code\]$(document).keydown(function(e){ if (e.keyCode == 37) { var url = $('a#left').attr("href"); if (url != '') { // require a URL window.location = url; // redirect } return false; } if (e.keyCode == 39) { var url = $('a#right').attr("href"); if (url != '') { // require a URL window.location = url; // redirect } return false; }});\[/code\]