Skip to content

Instantly share code, notes, and snippets.

@tsenart
Created April 4, 2011 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsenart/902681 to your computer and use it in GitHub Desktop.
Save tsenart/902681 to your computer and use it in GitHub Desktop.
Elegance analysis
document.body.addEventListener('keydown', function(e) {
([37, 39].indexOf(e.keyCode) > -1) && pres[{37:'prev',39:'next'}[e.keyCode]]();
});
// VERSUS
document.body.addEventListener('keydown', function(e) {
switch(e.keyCode) {
case 37:
pres.prev();
break;
case 39:
pres.next();
break;
default:
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment