On this page

# Keyboard

### 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
  - Keyboard.js, line 29

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
  - Keyboard.js, line 42

### stop()

Stop the keyboard running

Source
  - Keyboard.js, line 50

Type anything to view search result