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:
-
indexNumberthe index of the gamepad
Returns:
gamepad snapshot with all the info
getGamepadAxis
-
index -
name -
raw
Returns a gamepad snapshot if it is connected
Parameters:
-
indexNumberthe index of the gamepad
-
nameStringthe name of the axis (also you could specify the number)
-
rawBoolean[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:
-
indexNumberthe index of the gamepad
-
nameStringthe 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_codeNumber
Returns:
isMouseButtonPressed
-
button
returns true is the mouse button is pressed now
Parameters:
-
buttonNumbercould 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:
-
xNumberx coordinate of the mouse in canvas coordinates
-
yNumbery coordinate of the mouse in canvas coordinates (0 is bottom)
-
widthNumberrectangle width in pixels
-
heightNumberrectangle height in pixels
-
flipBoolean[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:
-
vBooleanif 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_codeNumber
Returns:
wasMouseButtonPressed
-
button
returns true is the mouse button was pressed between previous frame and now
Parameters:
-
buttonNumbercould be "left","middle","right" or GL.LEFT_MOUSE_BUTTON, GL.MIDDLE_MOUSE_BUTTON, GL.RIGHT_MOUSE_BUTTON
