KeyListener - Verge3D User Manual - Soft8Soft
Description: Learn how to use KeyListener in your interactive 3D apps made with Verge3D

# KeyListener

A simple class for registering keyup/keydown events and identifying if a key is currently being pressed.

## Constructor

### KeyListener(domElement : HTMLElement, mobileControlsContainerElement : HTMLElement)

domElement
  The HTML element to add event listeners to.
mobileControlsContainerElement
  The optional HTML element used as container for first-person controls on mobile devices.

## Properties

### # .isKeyDown : Object

An object whose keys are key codes from the Keys dictionary and values are boolean flags indicating if the corresponding key is currently being pressed.

### # .onKeyDown : Function

A callback triggered after the "keydown" event. Receives the "event" object as a parameter.

### # .onKeyUp : Function

A callback triggered after the "keyup" event. Receives the "event" object as a parameter.

## Methods

### # .dispose()

Remove all the event listeners.

## Source

For more info on how to obtain the source code of this module see this page.