Class: Input

Input()

new Input()

The static class that handles input data from the keyboard and gamepads.
Properties:
Name Type Description
keyRepeatWait Number [static] The wait time of the key repeat in frames.
keyRepeatInterval Number [static] The interval of the key repeat in frames.
keyMapper Object [static] A hash table to convert from a virtual key code to a mapped key name.
gamepadMapper Object [static] A hash table to convert from a gamepad button to a mapped key name.
dir4 Number [static][read-only] The four direction value as a number of the numpad, or 0 for neutral.
dir8 Number [static][read-only] The eight direction value as a number of the numpad, or 0 for neutral.
date Number [static][read-only] The time of the last input in milliseconds.
_currentState Object [static]{[key: string]: boolean}
_previousState Object [static]{[key: string]: boolean}
_gamepadStates Array.<Array.<Boolean>> [static]
_latestButton String [static]
_pressedTime Number [static]
_dir4 Number [static]
_dir8 Number [static]
_preferredAxis String [static]
_date Number [static]

Methods

(static) clear()

Clears all the input data.

(static) initialize()

Initializes the input system.

(static) isLongPressed(keyName) → {Boolean}

Checks whether a key is kept depressed.
Parameters:
Name Type Description
keyName String The mapped name of the key
Returns:
True if the key is long-pressed
Type
Boolean

(static) isPressed(keyName) → {Boolean}

Checks whether a key is currently pressed down.
Parameters:
Name Type Description
keyName String The mapped name of the key
Returns:
True if the key is pressed
Type
Boolean

(static) isRepeated(keyName) → {Boolean}

Checks whether a key is just pressed or a key repeat occurred.
Parameters:
Name Type Description
keyName String The mapped name of the key
Returns:
True if the key is repeated
Type
Boolean

(static) isTriggered(keyName) → {Boolean}

Checks whether a key is just pressed.
Parameters:
Name Type Description
keyName String The mapped name of the key
Returns:
True if the key is triggered
Type
Boolean

(static) update()

Updates the input data.