# JSDoc: Class: EventManager

# Class: EventManager

## core.EventManager(options)

This manager handles all participant interactions with the experiment, i.e. keyboard, mouse and touch events.

## Constructor

#### new EventManager(options)

##### Parameters:

Name | Type | Description
--- | --- | ---

`options`

Object

###### Properties

Name | Type | Description
--- | --- | ---
`psychoJS` | module:core.PsychoJS | the PsychoJS instance

Source:
  - core/EventManager.js, line 13

### Methods

#### addMouseListeners(renderer)

Add various mouse listeners to the Pixi renderer of the Window.

##### Parameters:

Name | Type | Description
--- | --- | ---
`renderer` | PIXI.Renderer | The Pixi renderer

Source:
  - core/EventManager.js, line 215

#### clearEvents()

Clear all events from the event buffer.

Source:
  - core/EventManager.js, line 150
To Do:
  - handle the attribs argument

#### clearKeys()

Clear all keys from the key buffer.

Source:
  - core/EventManager.js, line 164

#### getKeys(options) → {Array.<string>}

Get the list of keys pressed by the participant.

Note: The w3c key-event viewer can be used to see possible values for the items in the keyList given the user's keyboard and chosen layout. The "key" and "code" columns in the UI Events fields are the relevant values for the keyList argument.

##### Parameters:

Name | Type | Description
--- | --- | ---

`options`

Object

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`keyList` | Array.<string> | <optional> | null | keyList allows the user to specify a set of keys to check for. Only keypresses from this set of keys will be removed from the keyboard buffer. If no keyList is given, all keys will be checked and the key buffer will be cleared completely.
`timeStamped` | boolean | <optional> | false | If true will return a list of tuples instead of a list of keynames. Each tuple has (keyname, time).

Source:
  - core/EventManager.js, line 55

##### Returns:

the list of keys that were pressed.

Type
  Array.<string>

#### getMouseInfo() → {EventManager.MouseInfo}

Get the mouse info.

Source:
  - core/EventManager.js, line 137

##### Returns:

the mouse info.

Type
  EventManager.MouseInfo

#### keycode2w3c(keycode) → {string}

Convert a keycode to a W3C UI Event code.

This is for legacy browsers.

##### Parameters:

Name | Type | Description
--- | --- | ---
`keycode` | number | the keycode

Source:
  - core/EventManager.js, line 408

##### Returns:

corresponding W3C UI Event code

Type
  string

#### pyglet2w3c(pygletKeyList) → {Array.string}

Convert a keylist that uses pyglet key names to one that uses W3C KeyboardEvent.code values.

This allows key lists that work in the builder environment to work in psychoJS web experiments.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pygletKeyList` | Array.string | the array of pyglet key names

Source:
  - core/EventManager.js, line 358

##### Returns:

the w3c keyList

Type
  Array.string

#### resetMoveClock()

Reset the move clock.

Source:
  - core/EventManager.js, line 202
To Do:
  - not implemented

#### startMoveClock()

Start the move clock.

Source:
  - core/EventManager.js, line 176
To Do:
  - not implemented

#### stopMoveClock()

Stop the move clock.

Source:
  - core/EventManager.js, line 189
To Do:
  - not implemented

#### w3c2pyglet(code) → {string}

Convert a W3C Key Code into a pyglet key.

##### Parameters:

Name | Type | Description
--- | --- | ---
`code` | string | W3C Key Code

Source:
  - core/EventManager.js, line 386

##### Returns:

corresponding pyglet key

Type
  string