$(document).ready(function(){ $(window).keyup(function (event) { if ( event.keyCode == 37 ) document.location = $('#navleft').attr('href'); if ( event.keyCode == 39 ) document.location = $('#navright').attr('href'); }); });