Constructor
new Input()
Initialize Set objects to store names of keys pressed and released;
set up event listeners to handle keyboard input.
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 |
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 |
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 |
Returns:
true if the key was just released
- Type
- boolean
shutdown()
Stop this class from processing input by removing input listeners.
update()
Update key state data.
This method should be called once per frame by the Game class.
This method should be called once per frame by the Game class.