Keyboard

new Keyboard(Commands)

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

Parameters:
NameTypeDescription
CommandsArray.<Object>

array of keyboard command objects

Examples
// A command object looks like:
{
    key: 's',
    cmd: () => anim.start(),
}
// The array of keyboard commands looks like:
 const keyTemplates = [
     { 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') },
 ]
 const keyboard = new Keyboard(keyTemplates)

Methods

start()

Start the keyboard running

stop()

Stop the keyboard running