//process this function whenever a key is pressed
$(document).keypress(function (e) {
  //Next
  //if the keyCode or charCode is 110 (lower case n) or 78 (upper case N)
  if (e.keyCode == 39){
    //grab the href attribute from the link with the id "next_link"
    var next_link = $("a#next_link").attr("href");
    //if the next link exists (i.e if it's not the last page)
    if(next_link){
      //go to the next page
      window.location = next_link;
    }
  }
  //Previous
  //works exactly as the above example but for the 'p' and 'P' keys
  if (e.keyCode == 37){
    var prev_link = $("a#prev_link").attr("href");
    if(prev_link){
      window.location = prev_link;
    }
  }
});
