aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2018-11-13 10:48:23 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2018-11-13 10:48:23 +0100
commitf042a8c394718ebb7756aceb58f35d6204559779 (patch)
tree876d754441aa36b9498b1e6112aa719865bcc145
parentb6ce0a9724f123396b59e9b7b90ab2d44dda2534 (diff)
downloadperl-software-in-gnu-guix-f042a8c394718ebb7756aceb58f35d6204559779.tar
perl-software-in-gnu-guix-f042a8c394718ebb7756aceb58f35d6204559779.tar.gz
add cmd/ctrl + arrow key shortcuts to first/last slides
-rw-r--r--js/reveal.js40
-rw-r--r--plugin/search/search.js2
2 files changed, 25 insertions, 17 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 1c0e69d..f6f7903 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -318,17 +318,17 @@
// Holds information about the keyboard shortcuts
keyboardShortcuts = {
- 'N , SPACE': 'Next slide',
- 'P': 'Previous slide',
- '&#8592; , H': 'Navigate left',
- '&#8594; , L': 'Navigate right',
- '&#8593; , K': 'Navigate up',
- '&#8595; , J': 'Navigate down',
- 'Home': 'First slide',
- 'End': 'Last slide',
- 'B , .': 'Pause',
- 'F': 'Fullscreen',
- 'ESC, O': 'Slide overview'
+ 'N , SPACE': 'Next slide',
+ 'P': 'Previous slide',
+ '&#8592; , H': 'Navigate left',
+ '&#8594; , L': 'Navigate right',
+ '&#8593; , K': 'Navigate up',
+ '&#8595; , J': 'Navigate down',
+ 'Home , &#8984;/CTRL &#8592;': 'First slide',
+ 'End , &#8984;/CTRL &#8594;': 'Last slide',
+ 'B , .': 'Pause',
+ 'F': 'Fullscreen',
+ 'ESC, O': 'Slide overview'
},
// Holds custom key code mappings
@@ -4865,15 +4865,23 @@
onUserInput( event );
- // Check if there's a focused element that could be using
- // the keyboard
+ // Is there a focused element that could be using the keyboard?
var activeElementIsCE = document.activeElement && document.activeElement.contentEditable !== 'inherit';
var activeElementIsInput = document.activeElement && document.activeElement.tagName && /input|textarea/i.test( document.activeElement.tagName );
var activeElementIsNotes = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className);
+ // Whitelist specific modified + keycode combinations
+ var prevSlideShortcut = event.shiftKey && event.keyCode === 32;
+ var firstSlideShortcut = ( event.metaKey || event.ctrlKey ) && event.keyCode === 37;
+ var lastSlideShortcut = ( event.metaKey || event.ctrlKey ) && event.keyCode === 39;
+
+ // Prevent all other events when a modifier is pressed
+ var unusedModifier = !prevSlideShortcut && !firstSlideShortcut && !lastSlideShortcut &&
+ ( event.shiftKey || event.altKey || event.ctrlKey || event.metaKey );
+
// Disregard the event if there's a focused element or a
// keyboard modifier key is present
- if( activeElementIsCE || activeElementIsInput || activeElementIsNotes || (event.shiftKey && event.keyCode !== 32) || event.altKey || event.ctrlKey || event.metaKey ) return;
+ if( activeElementIsCE || activeElementIsInput || activeElementIsNotes || unusedModifier ) return;
// While paused only allow resume keyboard events; 'b', 'v', '.'
var resumeKeyCodes = [66,86,190,191];
@@ -4957,9 +4965,9 @@
// n, page down
case 78: case 34: navigateNext(); break;
// h, left
- case 72: case 37: navigateLeft(); break;
+ case 72: case 37: firstSlideShortcut ? slide( 0 ) : navigateLeft(); break;
// l, right
- case 76: case 39: navigateRight(); break;
+ case 76: case 39: lastSlideShortcut ? slide( Number.MAX_VALUE ) : navigateRight(); break;
// k, up
case 75: case 38: navigateUp(); break;
// j, down
diff --git a/plugin/search/search.js b/plugin/search/search.js
index 6d694d2..21c0367 100644
--- a/plugin/search/search.js
+++ b/plugin/search/search.js
@@ -200,7 +200,7 @@ function Hilitor(id, tag)
toggleSearch();
}
}, false );
- if( window.Reveal ) Reveal.registerKeyboardShortcut( 'Ctrl-Shift-F', 'Search' );
+ if( window.Reveal ) Reveal.registerKeyboardShortcut( 'CTRL + Shift + F', 'Search' );
closeSearch();
return { open: openSearch };
})();