Created
November 12, 2010 18:13
-
-
Save fabi1cazenave/674455 to your computer and use it in GitHub Desktop.
Experimental JavaScript file for HTML-Timing slideshows. Requires the latest version of timesheets.js (0.4+).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* add custom keyboard shortcuts for the slideshow player */ | |
EVENTS.onSMILReady(function() { | |
var slideshow = document.getElementById("slideshow"); | |
if (!slideshow || !slideshow.timing) return; | |
EVENTS.bind(document, "keydown", function(e) { | |
if (e.altKey || e.metaKey || e.cmdKey || e.ctrlKey) | |
return; | |
switch(e.keyCode) { | |
case 36: // home key | |
EVENTS.preventDefault(e); | |
slideshow.timing.first.click(); | |
break; | |
case 37: // left arrow key | |
EVENTS.preventDefault(e); | |
slideshow.timing.prev.click(); | |
break; | |
case 39: // right arrow key | |
EVENTS.preventDefault(e); | |
slideshow.timing.next.click(); | |
break; | |
case 35: // end key | |
EVENTS.preventDefault(e); | |
slideshow.timing.last.click(); | |
break; | |
case 32: // spacebar | |
EVENTS.preventDefault(e); | |
if (e.shiftKey) | |
slideshow.timing.prev.click(); | |
else | |
slideshow.timing.next.click(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment