?
Solved

Jquery navigation key

Posted on 2012-08-31
4
Medium Priority
?
310 Views
Last Modified: 2012-08-31
I am creating a web page with 'last record' , 'next record' buttons.
The users would like to be able to use keyboard shortcuts to quickly 'cursor' thru the records one at a time.

Would using alt-left arrow and alt-right arrow be good choices for this?

Could you rcommend this or another option that will work cross-browser and not stomp on any other browser functionality and show me how to code?

I already have the functions created to cursor the records
0
Comment
Question by:KeithMcElroy
  • 2
  • 2
4 Comments
 

Author Comment

by:KeithMcElroy
ID: 38354910
it would be helpful if the up and down arrows could be used for cursoring thru pages.

I have four buttons

Prev Page     alt-left arrow
Prev Record  alt  up arrow
Next Record  alt down arrow
Next Page  alt right arrow
0
 
LVL 45

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38354957
Something like this?

$(document).keydown(function (e) {
  var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 };

	switch (keyCode) {
		case arrow.left:
		alert("left");
		break;

		case arrow.up:
		alert("up");
		break;

		case arrow.right:
		alert("right");
		break;

		case arrow.down:
		alert("down");
		break;
	}
});

Open in new window

0
 

Author Comment

by:KeithMcElroy
ID: 38355365
Beautiful.  Works like a charm.

Thanks for helping me out.

keith
0
 
LVL 45

Expert Comment

by:Chris Stanyon
ID: 38355406
No worries ;)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question