How can I interactively jump to a specific slide?
Programmatically, I can use Reveal.slide( indexh, indexv, indexf).
For instance, in S5, I can enter the slide number and then press Enter.
How can I interactively jump to a specific slide?
Programmatically, I can use Reveal.slide( indexh, indexv, indexf).
For instance, in S5, I can enter the slide number and then press Enter.
I did this to set the E key to jump to the last slide and the J key to prompt me for the slide to go to:
<script>
Reveal.initialize({
keyboard: {
69: () => { Reveal.slide(Reveal.getSlides().length-1) },
74: () => { Reveal.slide(prompt("Slide no")-1) }
}
});
</script>
Or actually, since I use org-reveal, what I actually did was put this in my ORG file:
#+REVEAL_INIT_OPTIONS: keyboard: {69:()=>{Reveal.slide(Reveal.getSlides().length-1)},74:()=>{Reveal.slide(prompt("Slide no")-1)}}
For the latest version of Reveal, I used this to get it to work
Reveal.initialize({
keyboard: {
56: function() { Reveal.slide( 8 ) },
},
});
Just one note to the code of Amanda. Where can I put it? I didn't know: It's just in the index.html, at the end:
Reveal.initialize({
controls: false,
progress: true,
history: true,
center: true,
keyboard: {
13: 'next', // go to the next slide when the ENTER key is pressed
27: function() {}, // do something custom when ESC is pressed
32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding)
},
theme: Reveal.getQueryHash()
There are succinct instructions for overriding the default keybindings in the Reveal.js Documentation. They say this:
Reveal.configure({
keyboard: {
13: 'next', // go to the next slide when the ENTER key is pressed
27: function() {}, // do something custom when ESC is pressed
32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding)
}
});
Keycodes for numbers 1-9 are 49-57 (0 is 48), so my read of the reveal.js event.keycode
switch suggests you want something like:
Reveal.configure({
keyboard: {
56: slide( 8 ),
}
});
I'm not much of a jQuery whiz, but writing a function that notes any additional digits and waits for enter before jumping to slide n
seems like a sort of advanced beginner level challenge (and a question that plenty of folks here could help you with). Question: what should happen if I type a non-number before I get to enter? What does 5qenter do?
For what it's worth, I compiled a quick script that allows you to, e.g., jump to slide 17.3 by pressing
1
,7
,enter
,3
,enter
and then the slide jumps.