JavaScript jQuery switch page with arrows

Switch the page using the the left and the right arrow button on the keyboard

<script type='text/javascript'>
$(document).ready(function(){
	$(this).keypress(function(e) {
		var code = e.keyCode;
		var url = window.location.href;
		var part = url.split('=');
		var page;
		if (code == 39) { //right
			page = parseInt(part[1]) + 1;
		}
		if (code == 37) { //left
			page = parseInt(part[1]) - 1;
		}
		$(location).attr('href', part[0] + '=' + page);
	});
});
</script>