On this page

# Keyboard

### new Keyboard(keyModObjsopt, defaultModifieropt)

Creates an instance of Keyboard.

Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`keyModObjs` | Object | <optional> | [] | an array of objects
`defaultModifier` | * | <optional> |  | if no modifier, use the default if given The objects in the keyModObjs look like: { modifier: 'alt', key: 's', cmd: () => anim.start() } If modifier = '', then no modifier is used The cmd is generally an arrow function to insure it executes in the caller's name space Example: const keyModCmds = [ // These use the default modifier key, in this case the 'alt' key { key: 'q', cmd: () => console.log('q') }, { key: 'w', cmd: () => console.log('w') }, { key: '2', cmd: () => console.log('2') }, { key: 'F2', cmd: () => console.log('F2') }, { key: 'Backspace', cmd: () => console.log('Backspace') }, { key: 'ArrowDown', cmd: () => console.log('ArrowDown') }, { key: 'Enter', cmd: () => console.log('Enter') }, { 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(keyModCmds, 'alt')

Source
  - Keyboard.js, line 38

## Methods

### start()

Start the keyboard running

Source
  - Keyboard.js, line 107

### stop()

Stop the keyboard running

Source
  - Keyboard.js, line 136

Type anything to view search result