Members
_allowDefaultKeys
Which keys do not cause event.preventDefault to be called on keydown events.
By default this is the escape key and all function keys
- Source:
_axisThreshold
How far from center does an axis need to be to count as pressed?
- Source:
_buttonsToAltJoyButtons
Maps standard game buttons to alternate joypad buttons
- Source:
_buttonsToAltKeys
Maps standard game buttons to alternate keyboard keys
- Source:
_buttonsToJoyAxes
Maps standard game buttons to joypad axes
- Source:
_buttonsToJoyButtons
Maps standard game buttons to joypad buttons
- Source:
_buttonsToKeys
Maps standard game buttons to keyboard keys.
- Source:
_currentJoyAxes
gamepad axes states for the current frame
- Source:
_currentJoyButtons
gamepad button states for the current frame
- Source:
_currentKeys
Keyboard states for the current frame
- Source:
_currentMouseLeft
Is the left mouse button down this frame?
- Source:
_currentMouseRight
Is the right mouse button down this frame?
- Source:
_forceMouseLeftDown
Force the left mouse button state to be down this frame.
Used for the edge case in which a mouse button is clicked up and down all in the span of one frame.
- Source:
_forceMouseRightDown
Force the right mouse button state to be down this frame.
Used for the edge case in which a mouse button is clicked up and down all in the span of one frame.
- Source:
_keysRaw
Caches keyboard key states.
- Source:
_lastJoyAxes
gamepad axes states for the last frame
- Source:
_lastJoyButtons
gamepad button states for the last frame
- Source:
_lastKeys
Keyboard states for the last frame
- Source:
_lastMouseLeft
Was the left mouse button down last frame?
- Source:
_lastMouseRight
Was the right mouse button down last frame?
- Source:
canvas
Reference to the canvas used for mouse input.
Automatically added by the Engine.
- Source:
canvasScale
The scale of the canvas, aka the pixel size.
Added automatically by the Engine
- Source:
dataOnlyMode
This mode runs the engine without drawing to a canvas or playing audio.
This is useful to use the engine to generate image data.
- Source:
mouse
Object containing input state of the mouse.
mouse.isOffScreen,
mouse.position.x,
mouse.position.y,
mouse.left.pressed,
mouse.left.down,
mouse.left.up,
mouse.right.pressed,
mouse.right.down,
mouse.right.up
- Source:
screenHeight
The height of the game screen.
Not affected by this.canvasScale.
Added automatically by the Engine.
- Source:
screenWidth
The width of the game screen.
Not affected by this.canvasScale.
Added automatically by the Engine.
- Source:
Methods
_axisFromArrayIsPressed(axisIndex, axisArray)
Helper function for joypad axes
Parameters:
Name | Type | Description |
---|---|---|
axisIndex |
* | |
axisArray |
* |
- Source:
_keyDown(e)
handle window keydown events
Parameters:
Name | Type | Description |
---|---|---|
e |
* |
- Source:
_keyUp(e)
handle window keyup events
Parameters:
Name | Type | Description |
---|---|---|
e |
* |
- Source:
_pointerDown(e)
Handle pointerdown event
Parameters:
Name | Type | Description |
---|---|---|
e |
* |
- Source:
_pointerEnter()
Handle pointerenter event
- Source:
_pointerLeave()
handle pointerleave event
- Source:
_pointerMove(e)
Handle pointermove event
Parameters:
Name | Type | Description |
---|---|---|
e |
* |
- Source:
_pointerUp(e)
handle pointerup event
Parameters:
Name | Type | Description |
---|---|---|
e |
* |
- Source:
_updateButton(name, index)
Update the state for a standard game button.
Parameters:
Name | Type | Description |
---|---|---|
name |
* | |
index |
* |
- Source:
_updateButtons()
update standard game button states.
- Source:
clearInput()
clear out all of the input
- Source:
getButtonDown(buttonCode)
return true if the standard game button was pressed down this frame
Parameters:
Name | Type | Description |
---|---|---|
buttonCode |
number |
- Source:
getButtonPressed(buttonCode)
return true if the standard game button is currently held down
Parameters:
Name | Type | Description |
---|---|---|
buttonCode |
number |
- Source:
getButtonUp(buttonCode)
return true if the standard game button was released this frame
Parameters:
Name | Type | Description |
---|---|---|
buttonCode |
number |
- Source:
getJoyAxisDown(axisIndex)
return true if the joypad axis was pressed down this frame
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonDown
Parameters:
Name | Type | Description |
---|---|---|
axisIndex |
number |
- Source:
getJoyAxisPressed(axisIndex)
return true if the joypad axis is currently held down
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonPressed
Parameters:
Name | Type | Description |
---|---|---|
axisIndex |
number |
- Source:
getJoyAxisUp(axisIndex)
return true if the joypad axis was released this frame
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonUp
Parameters:
Name | Type | Description |
---|---|---|
axisIndex |
number |
- Source:
getJoyButtonDown(buttonIndex)
return true if the joypad button was pressed down this frame.
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonDown
Parameters:
Name | Type | Description |
---|---|---|
buttonIndex |
number |
- Source:
getJoyButtonPressed(buttonIndex)
return true if the joypad button is currently held down
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonPressed
Parameters:
Name | Type | Description |
---|---|---|
buttonIndex |
number |
- Source:
getJoyButtonUp(buttonIndex)
return true if the joypad button was released this frame.
This is the joypad from the Gamepad API, and generally should only
be used when detecting inputs to remap controls. For normal
gameplay use Input.getButtonUp
Parameters:
Name | Type | Description |
---|---|---|
buttonIndex |
number |
- Source:
getKeyDown(keyCode)
return true if the key was pressed down this frame
Parameters:
Name | Type | Description |
---|---|---|
keyCode |
number |
- Source:
getKeyPressed(keyCode)
return true if the key is currently held down
Parameters:
Name | Type | Description |
---|---|---|
keyCode |
number |
- Source:
getKeyUp(keyCode)
return true if the key was released this frame
Parameters:
Name | Type | Description |
---|---|---|
keyCode |
number |
- Source:
init()
Do initial setup. Add event listeners.
- Source:
pollInput()
Update the input, should be done first thing in the game loop.
Called automatically by the Engine.
- Source: