gs.Input Class
This class manages the input system. It needs to be initializes before any input data can be received. It supports keyboard, mouse, touch and gamepad input data.
The input system has a set of buttons called LEFT, UP, RIGHT, DOWN, A, B, C, X, Y, Z, L, R, START and SELECT which are emulated and available on most platforms. They are mapped to the different input devices like to the keys of a keyboard or the buttons on a gamepad.
Constructor
gs.Input
()
final
static
Item Index
Methods
Methods
clear
()
static
Clears all input states.
dir4
()
Number
static
Checkes if one of the 4 direction keys/buttons is pressed.
Returns:
0 = NONE, 2 = DOWN, 4 = LEFT, 6 = UP, 8 = RIGHT
dir8
()
Number
static
Checkes if one of the 8 direction keys/buttons is pressed.
Returns:
0 = NONE, 1 = DOWN-LEFT, 2 = DOWN, 3 = DOWN-RIGHT, 4 = LEFT, 5 = RIGHT-UP, 6 = UP, 7 = LEFT-UP, 8 = RIGHT
initialize
()
static
Initializes the input-system. Must be called before any input data can be received.
press
-
key
Checked if the specified key is pressed.
Parameters:
-
key
Number- The key to check.
Returns:
If true the key is pressed. Otherwise false.
release
-
key
Checked if the specified key is released.
Parameters:
-
key
Number- The key to check.
Returns:
If true the key is released. Otherwise false.
repeat
-
key
Checkes if the specified key is pressed. It checks if the user held down a key for certain time and then returns true in fixed time intervals.
Parameters:
-
key
Number- The key to check.
Returns:
Return true if the key is pressed. It checks then if the user held down a key for certain time and then returns true in fixed time intervals.
trigger
-
key
Checked if the specified key is triggered.
Parameters:
-
key
Number- The key to check.
Returns:
If true the key is triggered. Otherwise false.
update
()
static
Updates the input-system. Should be called once per frame.
Properties
Gamepad
gs.GamePad
static
Gives direct access to the gamepad
keyDown
Boolean
static
Indicates if a key is currently pressed.
keys
Uint8Array
static
Stores the state of the keyboard.
keyUp
Boolean
static
Indicates if a key is currently released.