LS.Input Class
Input is a static class used to read the input state (keyboard, mouse, gamepad, etc)
Constructor
LS.Input
()
Item Index
Methods
getGamepad
-
index
Returns a gamepad snapshot if it is connected
Parameters:
-
index
Numberthe index of the gamepad
Returns:
gamepad snapshot with all the info
getGamepadAxis
-
index
-
name
-
raw
Returns a gamepad snapshot if it is connected
Parameters:
-
index
Numberthe index of the gamepad
-
name
Stringthe name of the axis (also you could specify the number)
-
raw
Boolean[optional] if you want the data unfiltered
Returns:
axis value from -1 to 1
isGamepadButtonPressed
-
index
-
name
Returns if the given button of the specified gamepad is pressed
Parameters:
-
index
Numberthe index of the gamepad
-
name
Stringthe name of the button "A","B","X","Y","LB","RB","BACK","START","LS","RS" (also you could specify the number)
Returns:
if the button is pressed
isKeyPressed
-
key_code
returns true is the key is pressed now
Parameters:
-
key_code
Number
Returns:
isMouseButtonPressed
-
button
returns true is the mouse button is pressed now
Parameters:
-
button
Numbercould be "left","middle","right" or GL.LEFT_MOUSE_BUTTON, GL.MIDDLE_MOUSE_BUTTON, GL.RIGHT_MOUSE_BUTTON
Returns:
isMouseInRect
-
x
-
y
-
width
-
height
-
flip
returns if the mouse is inside the rect defined by x,y, width,height
Parameters:
-
x
Numberx coordinate of the mouse in canvas coordinates
-
y
Numbery coordinate of the mouse in canvas coordinates (0 is bottom)
-
width
Numberrectangle width in pixels
-
height
Numberrectangle height in pixels
-
flip
Boolean[optional] if you want to flip the y coordinate
Returns:
lockMouse
-
v
locks the mouse (to use with first person view cameras) so when the mouse moves, the cameras moves
Parameters:
-
v
Booleanif true, the camera is locked, otherwise unlocked
Returns:
mouseClick
()
Promise
Returns a Promise that will be fulfilled when the user clicks the screen
Returns:
wasKeyPressed
-
key_code
returns true is the key was pressed between previous frame and now
Parameters:
-
key_code
Number
Returns:
wasMouseButtonPressed
-
button
returns true is the mouse button was pressed between previous frame and now
Parameters:
-
button
Numbercould be "left","middle","right" or GL.LEFT_MOUSE_BUTTON, GL.MIDDLE_MOUSE_BUTTON, GL.RIGHT_MOUSE_BUTTON