Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

New key mappings #34

Merged
merged 3 commits into from

2 participants

@mahemoff

This patch adds:

hjkl for directions.
space and n for next slide, p for previous slide
esc for 3D overview (instead of space)

Rationale:
I think space is the most intuitive way to iterate through slides (as with PgDn, traverses down and right as appropriate) without even needing to provide any instructions. As many laptops don't have PgUp/PgDn, it's also necessary to provide a mapping for Previous, which is why I added "p" and therefore "n" for consistency.

I'd argue esc is more appropriate than space for the context-shift of the 3D overview.

Added vim bindings because they're convenient, some devices might not support arrow keys, and they're being used in Twitter and Google+ among other websites.

mahemoff added some commits
@mahemoff mahemoff Add new key mappings for navigation.
hjkl for directions.
space to move to next slide.
esc for 3D overview (instead of space)
1675002
@mahemoff mahemoff p for previous, n for next 75380e0
@mahemoff mahemoff ignore metaKey modifier too 83e4a1f
@hakimel hakimel merged commit 83e4a1f into hakimel:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 27, 2012
  1. @mahemoff

    Add new key mappings for navigation.

    mahemoff authored
    hjkl for directions.
    space to move to next slide.
    esc for 3D overview (instead of space)
  2. @mahemoff

    p for previous, n for next

    mahemoff authored
  3. @mahemoff

    ignore metaKey modifier too

    mahemoff authored
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 23 deletions.
  1. +23 −23 js/reveal.js
View
46 js/reveal.js
@@ -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 || event.metaKey ) 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 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
+ }
+ 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.
Something went wrong with that request. Please try again.