Class: Keyboard

Keyboard

The Keyboard class enabled keyboard input in Input The mapped "buttons" are the key codes or the character values. Which of the two depends on the Keyboard#useCode property.


new Keyboard()

Properties:
Name Type Description
mode Keyboard.MODE_KEY_VALUE

If Keyboard#MODE_KEY_LOCATION, the button mappings apply to key "codes" representing the key locations on the keyboard ("KeyA", "LeftShift", etc) as specified on a QWERTY keyboard. If , they apply to the pressed characters. By default it uses locations, making for example WASD controls work on Azerty keyboards where W = Z, A = Q. In either case, the old API's keycode will always be used as fallback so until the new KeyboardEvent API is implemented reliably by browsers, you should also map the old integer keyCodes.

{@see KeyboardEvent#code} {@see KeyboardEvent#key}

Author:
  • derschmale <http://www.derschmale.com>

Methods


mapAxis(negKey, posKey, action [, range])

Maps two keys to represent an axis. For example mapping "ArrowLeft" and "ArrowRight" can be mapped to (-1, 1).

Parameters:
Name Type Argument Description
negKey string

The key or character to represent the negative end of the axis.

posKey string

The key or character to represent the positive end of the axis.

action

The action to map the axis on.

range number <optional>

The maximum value the key represents. Defaults to 1.


unmap()