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