new Keyboard(Commands)
Creates an instance of Keyboard. The objects in the keyTemplates look like:
Parameters:
Name | Type | Description |
---|---|---|
Commands | Array.<Object> | array of keyboard command objects |
- Source
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
- Source
stop()
Stop the keyboard running
- Source