Navigate Pages Using the Left/Right Keyboard Arrows


/ Published in: jQuery
Save to your folder(s)

This is just a basic example of how you would allow navigation via left/right arrow keys. This is most commonly used when navigating multiple-image image galleries.


Copy this code and paste it in your HTML
  1. jQuery(document).keydown(function(e){
  2. if (e.which == 37) { // 37 is the left arrow key code.
  3. window.location.href = 'http://www.url.com';
  4. };
  5. if (e.which == 39) { // 39 is the right arrow key code.
  6. window.location.href = 'http://www.url.com';
  7. };
  8. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.