Class: Input

Input()

An Input object manages the keyboard input for a Game.
Check for discrete key events with keyPressed and keyReleased.
Check for continuous key events with keyPressing.
Methods check for key names such as "A", "3", "ArrowUp", "Shift", " " (space).
Names include effects of modifier keys, for example, "Shift" & "2" yields "@".
Also stores a Gamepad object that is automatically enabled when a gamepad is connected; check status from the boolean variable input.gamepad.active.

Constructor

new Input()

Initialize Set objects to store names of keys pressed and released; set up event listeners to handle keyboard input.
Source:

Methods

keyPressed(keyName) → {boolean}

Check if a key was just pressed; only true for a single frame after key is pressed.
Parameters:
Name Type Description
keyName string the name of the key to check
Source:
Returns:
true if the key was just pressed
Type
boolean

keyPressing(keyName) → {boolean}

Check if a key is currently down; true for the duration between key pressed and key released.
Parameters:
Name Type Description
keyName string the name of the key to check
Source:
Returns:
true if the key is currently down
Type
boolean

keyReleased(keyName) → {boolean}

Check if a key was just pressed; only true for a single frame after key is released.
Parameters:
Name Type Description
keyName string the name of the key to check
Source:
Returns:
true if the key was just released
Type
boolean

shutdown()

Stop this class from processing input by removing input listeners.
Source:

update()

Update key state data.
This method should be called once per frame by the Game class.
Source: