comparison poster/s62/slides.keys.js @ 3:1b34d9710a84

add poster
author ikkun <ikkun@cr.ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2021 10:51:57 +0900
parents
children
comparison
equal deleted inserted replaced
2:68a602b80b3f 3:1b34d9710a84
1
2 // todo: use class expression to "namespace"
3 // S6.Plugins.Keys or S6.DeckKeysPlugin for now ???
4
5
6 class S6_Plugin_Keys {
7
8 constructor( deck, options ) {
9
10 document.addEventListener( 'keydown', ev => {
11 if( ev.which == 34 || // PAGE DOWN
12 ev.which == 39 || // RIGHT
13 ev.which == 40 || // DOWN
14 (ev.which == 32 && !ev.shiftKey) // SPACE WITHOUT SHIFT
15 ) deck.next();
16
17 if( ev.which == 33 || // PAGE UP
18 ev.which == 37 || // LEFT
19 ev.which == 38 || // UP
20 (ev.which == 32 && ev.shiftKey) // SPACE + SHIFT
21 ) deck.prev();
22 });
23 }
24 } // class S6_Plugin_Keys
25
26
27
28 //////////////////////////////
29 // add global S6 "export"
30 // e.g. lets you call keys( options ) for plugins array config
31
32 var S6 = S6 || {};
33 S6.keys = options => deck => new S6_Plugin_Keys( deck, options );