Keyboard

new Keyboard(Commands, ModifierKey)

Creates an instance of Keyboard. The objects in the keyModObjs look like:

Parameters:
NameTypeDescription
CommandsArray.<Object>

array of keyboard command objects

ModifierKeyString

default modifier key(alt, shift, ..)

Examples
// A command object looks like:
{
    key: 's',
    cmd: () => anim.start(),
    modifier: 'alt', // if messing, use the constructor's default modifier
}
// The array of keyboard commands looks like:
 const keyCommands = [
     // These use the default modifier key, in this case the 'alt' key
     { key: 'q', cmd: () => console.log('q') },
     { key: '2', cmd: () => console.log('2') },
     { key: 'F2', cmd: () => console.log('F2') },
     { key: 'ArrowDown', cmd: () => console.log('ArrowDown') },
     { key: 'Escape', cmd: () => console.log('Escape') },
     // Here we override the default modifier key
     { modifier: 'shiftKey', key: 'a', cmd: () => console.log('shift A') },
     { modifier: 'None', key: 'b', cmd: () => console.log('b') },
     { modifier: '', key: 'c', cmd: () => console.log('c') }
 ]
 const keyboard = new Keyboard(keyCommands, 'alt')

Methods

start()

Start the keyboard running

stop()

Stop the keyboard running