API Docs for:
Show:

LS.Input Class

Defined in: ../src/input.js:2
Module: LS

Input is a static class used to read the input state (keyboard, mouse, gamepad, etc)

Constructor

LS.Input

()

Defined in ../src/input.js:2

Methods

getGamepad

(
  • index
)
Object

Defined in ../src/input.js:234

Returns a gamepad snapshot if it is connected

Parameters:

  • index Number

    the index of the gamepad

Returns:

Object:

gamepad snapshot with all the info

getGamepadAxis

(
  • index
  • name
  • raw
)
Number

Defined in ../src/input.js:247

Returns a gamepad snapshot if it is connected

Parameters:

  • index Number

    the index of the gamepad

  • name String

    the name of the axis (also you could specify the number)

  • raw Boolean

    [optional] if you want the data unfiltered

Returns:

Number:

axis value from -1 to 1

isGamepadButtonPressed

(
  • index
  • name
)
Boolean

Defined in ../src/input.js:275

Returns if the given button of the specified gamepad is pressed

Parameters:

  • index Number

    the index of the gamepad

  • name String

    the name of the button "A","B","X","Y","LB","RB","BACK","START","LS","RS" (also you could specify the number)

Returns:

Boolean:

if the button is pressed

isKeyPressed

(
  • key_code
)
Boolean

Defined in ../src/input.js:87

returns true is the key is pressed now

Parameters:

  • key_code Number

Returns:

Boolean:

isMouseButtonPressed

(
  • button
)
Boolean

Defined in ../src/input.js:111

returns true is the mouse button is pressed now

Parameters:

  • button Number

    could be "left","middle","right" or GL.LEFT_MOUSE_BUTTON, GL.MIDDLE_MOUSE_BUTTON, GL.RIGHT_MOUSE_BUTTON

Returns:

Boolean:

isMouseInRect

(
  • x
  • y
  • width
  • height
  • flip
)
Boolean

Defined in ../src/input.js:206

returns if the mouse is inside the rect defined by x,y, width,height

Parameters:

  • x Number

    x coordinate of the mouse in canvas coordinates

  • y Number

    y coordinate of the mouse in canvas coordinates (0 is bottom)

  • width Number

    rectangle width in pixels

  • height Number

    rectangle height in pixels

  • flip Boolean

    [optional] if you want to flip the y coordinate

Returns:

Boolean:

lockMouse

(
  • v
)
Boolean

Defined in ../src/input.js:151

locks the mouse (to use with first person view cameras) so when the mouse moves, the cameras moves

Parameters:

  • v Boolean

    if true, the camera is locked, otherwise unlocked

Returns:

Boolean:

mouseClick

() Promise

Defined in ../src/input.js:300

Returns a Promise that will be fulfilled when the user clicks the screen

Returns:

Promise:

wasKeyPressed

(
  • key_code
)
Boolean

Defined in ../src/input.js:99

returns true is the key was pressed between previous frame and now

Returns:

Boolean:

wasMouseButtonPressed

(
  • button
)
Boolean

Defined in ../src/input.js:131

returns true is the mouse button was pressed between previous frame and now

Parameters:

  • button Number

    could be "left","middle","right" or GL.LEFT_MOUSE_BUTTON, GL.MIDDLE_MOUSE_BUTTON, GL.RIGHT_MOUSE_BUTTON

Returns:

Boolean: