view 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
line wrap: on
line source


// todo: use class expression to "namespace"
//   S6.Plugins.Keys  or S6.DeckKeysPlugin for now ???


class S6_Plugin_Keys {

   constructor( deck, options ) {

     document.addEventListener( 'keydown', ev => {
       if( ev.which == 34 || // PAGE DOWN
           ev.which == 39 || // RIGHT
           ev.which == 40 || // DOWN
          (ev.which == 32 && !ev.shiftKey)  // SPACE WITHOUT SHIFT
         ) deck.next();

       if( ev.which == 33 || // PAGE UP
           ev.which == 37 || // LEFT
           ev.which == 38 || // UP
          (ev.which == 32 && ev.shiftKey)  // SPACE + SHIFT
         ) deck.prev();
    });
  }
} // class S6_Plugin_Keys



//////////////////////////////
// add global S6 "export"
//   e.g. lets you call keys( options ) for plugins array config

var S6 = S6 || {};
S6.keys = options => deck => new S6_Plugin_Keys( deck, options );