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:84

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:97

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:125

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

isMouseButtonPressed

(
  • name
)
Boolean

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

Returns if the given mouse button is pressed

Parameters:

  • name String

    the name of the button "LEFT","MIDDLE,"RIGHT" (also you could specify the number)

Returns:

Boolean:

if the button is pressed

isMouseInRect

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

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

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: