I am using the following code, along with jQuery, to enable keyboard navigation with the left and right arrow keys between various pages of a website. However, I also need to have a form on some of the pages. So, I need for the keyboard navigation to be disabled whenever the visitor is using one of the form fields and then re-enabled when a form field is no longer in use. What can I add to this code to achieve this?
$(function() {
$(document).keyup(function(e) {
switch(e.keyCode) {
case 37 : window.location = $('.prev').attr('href'); break;
case 39 : window.location = $('.next').attr('href'); break;
}
});
});