How can I make Reveal.js work with a presenter remote?

Crell picture Crell · Oct 28, 2013 · Viewed 7.5k times · Source

I'm loving Reveal.js so far. One issue I have, though, is that my wireless presentation remote is, as is typical, only capable of generating left/right arrow keystrokes. My Reveal.js slide decks make heavy use of its 2-dimensional capabilities, as well as fragments. That means my remote only goes to the right, not down.

The Reveal.js API looks like it should be strong enough to wire something in so that "right arrow" will first advance down if possible, then right, taking fragments into account. Unfortunately my JS-fu is not that strong, so I figured I'd ask if someone else had done something like this before and had some pointers. If there's some other approach that would work better, I'm open to that, too. I just don't want to be physically bound to my keyboard.

Answer

Cvuorinen picture Cvuorinen · Oct 28, 2013

What you want is that it would navigate to "next" instead of "right", which is the default binding for right arrow key. You can achieve this by overriding the default key bindings. There is some documentation here: https://github.com/hakimel/reveal.js/#keyboard-bindings

In your case you would like the right arrow key (keycode 39) to bind to "next" and probably also override left arrow key (keycode 37) to bind to "prev". Here is the sample code (add this to the Reveal.initialize configuration add the end of the file):

keyboard: {
    39: 'next',
    37: 'prev'
}