Permalink
Browse files

Pressing shift+space now goes to previous slide.

Added a shiftKeyActive boolean variable, and a keyUp() event.
  • Loading branch information...
1 parent bbf65e6 commit 6ea7931ee88267dc76a6e9370f1bf1542f718cf8 @nelstrom nelstrom committed Apr 16, 2010
Showing with 19 additions and 2 deletions.
  1. +19 −2 public/js/showoff.js
View
@@ -15,6 +15,7 @@ var incrCurr = 0
var incrCode = false
var debugMode = false
var gotoSlidenum = 0
+var shiftKeyActive = false
function setupPreso(load_slides, prefix) {
@@ -32,6 +33,7 @@ function setupPreso(load_slides, prefix) {
// bind event handlers
document.onkeydown = keyDown
+ document.onkeyup = keyUp
/* window.onresize = resized; */
/* window.onscroll = scrolled; */
/* window.onunload = unloaded; */
@@ -250,7 +252,7 @@ function keyDown(event)
if (event.ctrlKey || event.altKey || event.metaKey)
return true;
- debug('key: ' + key)
+ debug('keyDown: ' + key)
if (key >= 48 && key <= 57) // 0 - 9
{
@@ -265,9 +267,14 @@ function keyDown(event)
}
gotoSlidenum = 0;
+ if (key == 16) // shift key
+ {
+ shiftKeyActive = true;
+ }
if (key == 32) // space bar
{
- nextStep()
+ if (shiftKeyActive) { prevStep() }
+ else { nextStep() }
}
else if (key == 68) // 'd' for debug
{
@@ -308,6 +315,16 @@ function keyDown(event)
return true
}
+function keyUp(event) {
+ var key = event.keyCode;
+ debug('keyUp: ' + key);
+ if (key == 16) // shift key
+ {
+ shiftKeyActive = false;
+ }
+}
+
+
function swipeLeft() {
prevStep()
}

0 comments on commit 6ea7931

Please sign in to comment.