Add new key mappings for navigation.
authorMahemoff <michael@mahemoff.com>
Fri, 27 Apr 2012 14:09:35 +0000 (15:09 +0100)
committerMahemoff <michael@mahemoff.com>
Fri, 27 Apr 2012 14:09:35 +0000 (15:09 +0100)
hjkl for directions.
space to move to next slide.
esc for 3D overview (instead of space)

js/reveal.js

index f6de51d47043f42428663a358c7530bf824d9483..835c2a35f1bb3183d0a1f041ee9b39f20993a0a1 100644 (file)
@@ -155,33 +155,32 @@ var Reveal = (function(){
                // FFT: Use document.querySelector( ':focus' ) === null 
                // instead of checking contentEditable?
 
-               if( event.target.contentEditable === 'inherit' ) {
-                       if( event.keyCode >= 33 && event.keyCode <= 40 ) {
+               if ( event.target.contentEditable != 'inherit' ||
+                       event.shiftKey || event.altKey || event.ctrlKey ) return;
                                
-                               switch( event.keyCode ) {
-                                       case 33: navigatePrev(); break; // prev for wireless presenter (PgUp)
-                                       case 34: navigateNext(); break; // next for wireless presenter (PgDn)
-                                       case 37: navigateLeft(); break; // left
-                                       case 39: navigateRight(); break; // right
-                                       case 38: navigateUp(); break; // up
-                                       case 40: navigateDown(); break; // down
-                               }
-                               
-                               event.preventDefault();
-                               
-                       }
-                       // Space bar
-                       else if ( event.keyCode === 32 && supports3DTransforms ) {
-                               if( overviewIsActive() ) {
-                                       deactivateOverview();
-                               }
-                               else {
-                                       activateOverview();
-                               }
+               var triggered = false;
+               switch( event.keyCode ) {
+                       case 33: navigatePrev(); triggered = true; break; // prev for wireless presenter (PgUp)
+                       case 32: case 34: navigateNext(); triggered = true; break; // next for wireless presenter (PgDn, Space)
+                       case 72: case 37: navigateLeft(); triggered = true; break; // h, left
+                       case 76: case 39: navigateRight(); triggered = true; break; // l, right
+                       case 75: case 38: navigateUp(); triggered = true; break; // k, up
+                       case 74: case 40: navigateDown(); triggered = true; break; // j, down
+               }
+               if (triggered) return event.preventDefault()
 
-                               event.preventDefault();
+               if ( event.keyCode === 27 && supports3DTransforms ) {
+
+                       if( overviewIsActive() ) {
+                               deactivateOverview();
+                       }
+                       else {
+                               activateOverview();
                        }
+       
+                       event.preventDefault();
                }
+
        }
        
        /**
@@ -231,6 +230,7 @@ var Reveal = (function(){
                }
        }
 
+
        /**
         * Handles mouse wheel scrolling, throttled to avoid 
         * skipping multiple slides.