LittleJS Input System
- Tracks keyboard down, pressed, and released
- Tracks mouse buttons, position, and wheel
- Tracks multiple analog gamepads
- Touch input is handled as mouse input
- Virtual gamepad for touch devices
- Source
Members
(static, constant) isTouchDevice
True if a touch device has been detected
- Source
(static) isUsingGamepad :Boolean
Returns true if user is using gamepad (has more recently pressed a gamepad button)
- Boolean
- Source
(static) mousePos :Vector2
Mouse pos in world space
- Source
(static) mousePosScreen :Vector2
Mouse pos in screen space
- Source
(static) mouseWheel :Number
Mouse wheel delta this frame
- Number
- Source
(static) preventDefaultInput :Boolean
Prevents input continuing to the default browser handling (false by default)
- Boolean
- Source
Methods
(static) clearInput()
Clears all input
- Source
(static) gamepadIsDown(button, gamepadopt) → {Boolean}
Returns true if gamepad button is down
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
button | Number | |||
gamepad | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) gamepadStick(stick, gamepadopt) → {Vector2}
Returns gamepad stick value
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
stick | Number | |||
gamepad | Number | <optional> | 0 |
- Source
- Type:
- Vector2
(static) gamepadWasPressed(button, gamepadopt) → {Boolean}
Returns true if gamepad button was pressed
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
button | Number | |||
gamepad | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) gamepadWasReleased(button, gamepadopt) → {Boolean}
Returns true if gamepad button was released
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
button | Number | |||
gamepad | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) keyIsDown(key, deviceopt) → {Boolean}
Returns true if device key is down
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key | String | | |||
device | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) keyWasPressed(key, deviceopt) → {Boolean}
Returns true if device key was pressed this frame
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key | String | | |||
device | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) keyWasReleased(key, deviceopt) → {Boolean}
Returns true if device key was released this frame
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key | String | | |||
device | Number | <optional> | 0 |
- Source
- Type:
- Boolean
(static) mouseIsDown(button) → {Boolean}
Returns true if mouse button is down
Name | Type | Description |
---|---|---|
button | Number |
- Source
- Type:
- Boolean
(static) mouseWasPressed(button) → {Boolean}
Returns true if mouse button was pressed
Name | Type | Description |
---|---|---|
button | Number |
- Source
- Type:
- Boolean
(static) mouseWasReleased(button) → {Boolean}
Returns true if mouse button was released
Name | Type | Description |
---|---|---|
button | Number |
- Source
- Type:
- Boolean
(static) vibrate(patternopt)
Pulse the vibration hardware if it exists
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pattern | Number | | <optional> | 100 | single value in ms or vibration interval array |
- Source
(static) vibrateStop()
Cancel any ongoing vibration
- Source