Skip to content

Instantly share code, notes, and snippets.

@fabi1cazenave
Created November 12, 2010 18:13
Show Gist options
  • Save fabi1cazenave/674455 to your computer and use it in GitHub Desktop.
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+).
/* 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