synthing

a waveform sequencing synth on the web
Log | Files | Refs | Submodules

index.js (737B)


      1 import { h } from 'preact';
      2 import keymage from 'keymage';
      3 import { store } from '../store.js';
      4 
      5 const keybindings = {
      6     'shift-/': () => {store.dispatch({type: 'TOGGLE_HELP_OPEN'})},
      7     'space': {
      8         'a': () => {console.log('a pressed after space')}
      9     }
     10 }
     11 
     12 const getPrefix = (key, prefix) => prefix ? `${prefix} ${key}` : key;
     13 const registerAll = (keys, prefix) => {
     14     for (let key of Object.keys(keys)) {
     15         if (typeof(keys[key]) === "function") {
     16             keymage(getPrefix(key, prefix), keys[key]);
     17         }
     18         else if (typeof(keys[key]) === "object") {
     19             registerAll(keys[key], getPrefix(key, prefix));
     20         }
     21     }
     22 }
     23 registerAll(keybindings);
     24 
     25 export default () => (<div>{keybindings}</div>)