Skip to content

Instantly share code, notes, and snippets.

@taboularasa
Created March 9, 2009 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taboularasa/76045 to your computer and use it in GitHub Desktop.
Save taboularasa/76045 to your computer and use it in GitHub Desktop.
Key Press Navigation with jQuery
$(document).ready(function()
{
// hides all DIVs with the CLASS container
// and displays the one with the ID 'home' only
$(".container").css("display","none");
$("#home").css("display","block");
// makes the navigation work after all containers have bee hidden
showViaLink($("ul#navigation li a"));
// listens for any navigation keypress activity
$(document).keypress(function(e)
{
switch(e.which)
{
// user presses enter
case 13: showViaKeypress("#home");
break;
// user presses space
case 32: showViaKeypress("#about");
break;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment