merge keyboard shortcut changes
authorHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 28 Apr 2012 15:50:22 +0000 (11:50 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 28 Apr 2012 15:50:22 +0000 (11:50 -0400)
README.md
index.html
js/reveal.js
js/reveal.min.js

index f2ee48beeb801189a3ff44c501d9ac2fc6b7ea1e..d3c222860488d99c0e6e4accf2f3cef398808361 100644 (file)
--- a/README.md
+++ b/README.md
@@ -97,6 +97,7 @@ document.addEventListener( 'someState', function() {
 ## History
 
 #### 1.3 (master)
+- Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
 
 #### 1.2
 
@@ -151,4 +152,4 @@ document.addEventListener( 'someState', function() {
 
 MIT licensed
 
-Copyright (C) 2011 Hakim El Hattab, http://hakim.se
\ No newline at end of file
+Copyright (C) 2012 Hakim El Hattab, http://hakim.se
\ No newline at end of file
index 22b159a3cd62e8416981a0c40933eba4503df910..69d598f3df52f78ea7f351a6398380f1e67d7b3c 100644 (file)
@@ -82,7 +82,7 @@
                                <section>
                                        <h2>Holistic Overview</h2>
                                        <p>
-                                               Press <strong>SPACE</strong> to enter the slide overview!
+                                               Press <strong>ESC</strong> to enter the slide overview!
                                        </p>
                                </section>
 
index 4ba8a7be181cc73ffadb446b340abf1c6ba75923..237386dc3f7705e7d5ffac86078ccf76de3912c8 100644 (file)
@@ -3,7 +3,7 @@
  * http://lab.hakim.se/reveal-js
  * MIT licensed
  * 
- * Copyright (C) 2011 Hakim El Hattab, http://hakim.se
+ * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
  */
 var Reveal = (function(){
        
@@ -37,7 +37,8 @@ var Reveal = (function(){
                supports3DTransforms =  document.body.style['perspectiveProperty'] !== undefined ||
                                                                document.body.style['WebkitPerspective'] !== undefined || 
                                        document.body.style['MozPerspective'] !== undefined ||
-                                       document.body.style['msPerspective'] !== undefined,
+                                       document.body.style['msPerspective'] !== undefined ||
+                                       document.body.style['OPerspective'] !== undefined,
         
         supports2DTransforms =  document.body.style['transformProperty'] !== undefined ||
                                                                document.body.style['WebkitTransform'] !== undefined || 
@@ -155,22 +156,31 @@ var Reveal = (function(){
                // FFT: Use document.querySelector( ':focus' ) === null 
                // instead of checking contentEditable?
 
-               if ( event.target.contentEditable != 'inherit' ||
-                       event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
+               // Disregard the event if the target is editable or a 
+               // modifier is present
+               if ( event.target.contentEditable != 'inherit' || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
                                
                var triggered = false;
+
                switch( event.keyCode ) {
-                       case 80: case 33: navigatePrev(); triggered = true; break; // prev for wireless presenter (PgUp)
-                       case 78: 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
+                       // p, page up
+                       case 80: case 33: navigatePrev(); triggered = true; break; 
+                       // n, page down, space
+                       case 78: case 32: case 34: navigateNext(); triggered = true; break;
+                       // h, left
+                       case 72: case 37: navigateLeft(); triggered = true; break;
+                       // l, right
+                       case 76: case 39: navigateRight(); triggered = true; break;
+                       // k, up
+                       case 75: case 38: navigateUp(); triggered = true; break;
+                       // j, down
+                       case 74: case 40: navigateDown(); triggered = true; break;
+               }
+
+               if( triggered ) {
+                       event.preventDefault();
                }
-               if (triggered) return event.preventDefault()
-
-               if ( event.keyCode === 27 && supports3DTransforms ) {
-
+               else if ( event.keyCode === 27 && supports3DTransforms ) {
                        if( overviewIsActive() ) {
                                deactivateOverview();
                        }
index 955891cd56a129b7c1b4c2373b6369a5af69a941..749bdcdc7c0f48ac245219dca75eb81504842b44 100644 (file)
@@ -3,9 +3,9 @@
  * http://lab.hakim.se/reveal-js
  * MIT licensed
  * 
- * Copyright (C) 2011 Hakim El Hattab, http://hakim.se
+ * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
  */
-var Reveal=(function(){var i="#reveal .slides>section",a="#reveal .slides>section.present>section",j=0,c=0,E={controls:false,progress:false,history:false,transition:"default",theme:"default",mouseWheel:true,rollingLinks:true},K=[],d={},F=document.body.style.perspectiveProperty!==undefined||document.body.style.WebkitPerspective!==undefined||document.body.style.MozPerspective!==undefined||document.body.style.msPerspective!==undefined,k=document.body.style.transformProperty!==undefined||document.body.style.WebkitTransform!==undefined||document.body.style.MozTransform!==undefined||document.body.style.msTransform!==undefined||document.body.style.OTransform!==undefined,t=0,w=0;
+var Reveal=(function(){var i="#reveal .slides>section",a="#reveal .slides>section.present>section",j=0,c=0,E={controls:false,progress:false,history:false,transition:"default",theme:"default",mouseWheel:true,rollingLinks:true},K=[],d={},F=document.body.style.perspectiveProperty!==undefined||document.body.style.WebkitPerspective!==undefined||document.body.style.MozPerspective!==undefined||document.body.style.msPerspective!==undefined||document.body.style.OPerspective!==undefined,k=document.body.style.transformProperty!==undefined||document.body.style.WebkitTransform!==undefined||document.body.style.MozTransform!==undefined||document.body.style.msTransform!==undefined||document.body.style.OTransform!==undefined,t=0,w=0;
 function g(M){if(!k&&!F){document.body.setAttribute("class","no-transforms");return;}d.wrapper=document.querySelector("#reveal");d.progress=document.querySelector("#reveal .progress");
 d.progressbar=document.querySelector("#reveal .progress span");d.controls=document.querySelector("#reveal .controls");d.controlsLeft=document.querySelector("#reveal .controls .left");
 d.controlsRight=document.querySelector("#reveal .controls .right");d.controlsUp=document.querySelector("#reveal .controls .up");d.controlsDown=document.querySelector("#reveal .controls .down");
@@ -13,10 +13,11 @@ document.addEventListener("keydown",J,false);document.addEventListener("touchsta
 d.controlsRight.addEventListener("click",m(h),false);d.controlsUp.addEventListener("click",m(p),false);d.controlsDown.addEventListener("click",m(y),false);
 o(E,M);if(F===false){E.transition="linear";}if(E.controls){d.controls.style.display="block";}if(E.progress){d.progress.style.display="block";}if(E.transition!=="default"){d.wrapper.classList.add(E.transition);
 }if(E.theme!=="default"){d.wrapper.classList.add(E.theme);}if(E.mouseWheel){document.addEventListener("DOMMouseScroll",l,false);document.addEventListener("mousewheel",l,false);
-}if(E.rollingLinks){B();}A();}function o(N,M){for(var O in M){N[O]=M[O];}}function m(M){return function(N){N.preventDefault();M.call();};}function J(M){if(M.target.contentEditable==="inherit"){if(M.keyCode>=33&&M.keyCode<=40){switch(M.keyCode){case 33:G();
-break;case 34:s();break;case 37:v();break;case 39:h();break;case 38:p();break;case 40:y();break;}M.preventDefault();}else{if(M.keyCode===32&&F){if(H()){I();
-}else{z();}M.preventDefault();}}}}function u(P){if(P.touches.length===1){if(P.target.tagName.toLowerCase()==="a"||P.target.tagName.toLowerCase()==="img"){return;
-}P.preventDefault();var N={x:P.touches[0].clientX,y:P.touches[0].clientY};var M=window.innerWidth*0.3;var O=window.innerHeight*0.3;if(N.x<M){v();}else{if(N.x>window.innerWidth-M){h();
+}if(E.rollingLinks){B();}A();}function o(N,M){for(var O in M){N[O]=M[O];}}function m(M){return function(N){N.preventDefault();M.call();};}function J(N){if(N.target.contentEditable!="inherit"||N.shiftKey||N.altKey||N.ctrlKey||N.metaKey){return;
+}var M=false;switch(N.keyCode){case 80:case 33:G();M=true;break;case 78:case 32:case 34:s();M=true;break;case 72:case 37:v();M=true;break;case 76:case 39:h();
+M=true;break;case 75:case 38:p();M=true;break;case 74:case 40:y();M=true;break;}if(M){N.preventDefault();}else{if(N.keyCode===27&&F){if(H()){I();}else{z();
+}N.preventDefault();}}}function u(P){if(P.touches.length===1){if(P.target.tagName.toLowerCase()==="a"||P.target.tagName.toLowerCase()==="img"){return;}P.preventDefault();
+var N={x:P.touches[0].clientX,y:P.touches[0].clientY};var M=window.innerWidth*0.3;var O=window.innerHeight*0.3;if(N.x<M){v();}else{if(N.x>window.innerWidth-M){h();
 }else{if(N.y<O){p();}else{if(N.y>window.innerHeight-O){y();}}}}b();}}function l(M){clearTimeout(t);t=setTimeout(function(){var N=M.detail||-M.wheelDelta;
 if(N>0){s();}else{G();}},100);}function r(M){A();}function B(){if(F){var N=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var O=0,M=N.length;
 O<M;O++){var P=N[O];if(P.textContent&&!P.querySelector("img")&&(!P.className||!P.classList.contains(P,"roll"))){P.classList.add("roll");P.innerHTML='<span data-title="'+P.text+'">'+P.innerHTML+"</span>";