From 0ef90e0dcf289e81414faecc8122825532d1689d Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Fri, 20 Jul 2012 22:20:07 -0400 Subject: [PATCH] 'keyboard' config option for disabling keyboard navigation (closes #84) --- README.md | 6 +++++- js/reveal.js | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 298c1cf..05999e4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ Reveal.initialize({ // Push each slide change to the browser history history: false, + // Enable keyboard shortcuts for navigation + keyboard: true, + // Loop the presentation loop: false, @@ -168,7 +171,7 @@ You can change the appearance of the speaker notes by editing the file at `plugi #### 1.4 (master/beta) - Main #reveal container is now selected via a class instead of ID - API methods for adding or removing all event listeners -- The 'slidechange' event now includes currentSlide and previousSlide +- The ```slidechange``` event now includes currentSlide and previousSlide - Fixed bug where 'slidechange' was firing twice when history was enabled - Folder structure updates for scalability (see /lib & /plugin) - Slide notes by [rmurphey](https://github.com/rmurphey) @@ -177,6 +180,7 @@ You can change the appearance of the speaker notes by editing the file at `plugi - Added 'autoSlide' config - Bug fix: The 'slidechanged' event is now firing upon 'hashchange'. Thanks [basecode](https://github.com/basecode) - Bug fix: JS error when the 'progress' option was true but there was no progress DOM element +- ```keyboard``` config flag for disabling all keyboard navigation #### 1.3 - Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff) diff --git a/js/reveal.js b/js/reveal.js index e0be839..7811218 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -27,6 +27,9 @@ var Reveal = (function(){ // Push each slide change to the browser history history: false, + // Enable keyboard shortcuts for navigation + keyboard: true, + // Loop the presentation loop: false, @@ -179,12 +182,15 @@ var Reveal = (function(){ } function addEventListeners() { - document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchend', onDocumentTouchEnd, false ); window.addEventListener( 'hashchange', onWindowHashChange, false ); + if( config.keyboard ) { + document.addEventListener( 'keydown', onDocumentKeyDown, false ); + } + if ( config.controls && dom.controls ) { dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false ); dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false ); -- 2.26.2