Revision: 37858
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 18, 2010 14:53 by FatFolderDesigner
Initial Code
function keycatch(){ var keypress = event.keyCode var h1tags = document.body.getElementsByTagName("h1"); switch(keypress){ case 37: // Left if(currentpos!=0){ currentpos = currentpos-1; h1tags[currentpos].scrollIntoView(); } return false break; case 39: // Right if(h1tags[currentpos+1]!=undefined){ currentpos = currentpos+1; h1tags[currentpos].scrollIntoView(); } return false break; } }
Initial URL
http://fatfolderdesign.com/125/code/working-with-javascript-key-input
Initial Description
Starting with GoogleTV in mind I made a script to help navigate a page key basic key inputs, in this case I'm using the left and right arrows to jump between the H1 tags on a page, although the modifications to make it do other things would be very simple. Theres a more working concept on the link so you can see it in action without any coding on your part (and participate in some proper reading). There is one downside to this method, if manually scrolling down past an H1 tag it does not realize it, but I'll work on that once I get a chance
Initial Title
Javascript Keyboard Navigation
Initial Tags
javascript, navigation
Initial Language
JavaScript