Input
Index
Enumerations
Classes
Interfaces
Type Aliases
Enumerations
Axes
LeftStickX
Left analogue stick X direction
LeftStickY
Left analogue stick Y direction
RightStickX
Right analogue stick X direction
RightStickY
Right analogue stick Y direction
Buttons
Gamepad Buttons enumeration
DpadDown
D-pad down
DpadLeft
D-pad left
DpadRight
D-pad right
DpadUp
D-pad up
Face1
Face 1 button (e.g. A)
Face2
Face 2 button (e.g. B)
Face3
Face 3 button (e.g. X)
Face4
Face 4 button (e.g. Y)
LeftBumper
Left bumper button
LeftStick
Left analog stick press (e.g. L3)
LeftTrigger
Left trigger button
RightBumper
Right bumper button
RightStick
Right analog stick press (e.g. R3)
RightTrigger
Right trigger button
Select
Select button
Start
Start button
Keys
Enum representing physical input key codes
A
AltLeft
AltRight
ArrowDown
ArrowLeft
ArrowRight
ArrowUp
B
Backquote
Backslash
Backspace
BracketLeft
BracketRight
C
Comma
ContextMenu
ControlLeft
ControlRight
D
Delete
Digit0
Digit1
Digit2
Digit3
Digit4
Digit5
Digit6
Digit7
Digit8
Digit9
Down
E
Enter
Equal
Esc
Escape
F
F1
F10
F11
F12
F2
F3
F4
F5
F6
F7
F8
F9
G
H
I
J
K
Key0
Key1
Key2
Key3
Key4
Key5
Key6
Key7
Key8
Key9
KeyA
KeyB
KeyC
KeyD
KeyE
KeyF
KeyG
KeyH
KeyI
KeyJ
KeyK
KeyL
KeyM
KeyN
KeyO
KeyP
KeyQ
KeyR
KeyS
KeyT
KeyU
KeyV
KeyW
KeyX
KeyY
KeyZ
L
Left
M
MetaLeft
MetaRight
Minus
N
Num0
Num1
Num2
Num3
Num4
Num5
Num6
Num7
Num8
Num9
NumAdd
NumDecimal
NumDivide
NumLock
NumMultiply
NumSubtract
Numpad0
Numpad1
Numpad2
Numpad3
Numpad4
Numpad5
Numpad6
Numpad7
Numpad8
Numpad9
NumpadAdd
NumpadDecimal
NumpadDivide
NumpadEnter
NumpadMultiply
NumpadSubtract
O
P
Period
Q
Quote
R
Right
S
Semicolon
ShiftLeft
ShiftRight
Slash
Space
T
U
Up
V
W
X
Y
Z
NativePointerButton
Native browser button enumeration
Left
Middle
NoButton
Right
Unknown
PointerButton
The mouse button being pressed.
Left
Middle
NoButton
Right
Unknown
PointerScope
Determines the scope of handling mouse/touch events.
Canvas
Handle events on the canvas
element only. Events originating outside the
canvas
will not be handled.
Document
Handles events on the entire document. All events will be handled by Excalibur.
PointerType
The type of pointer for a [[PointerEvent]].
Mouse
Pen
Touch
Unknown
WheelDeltaMode
Line
Page
Pixel
Classes
Gamepad
Gamepad holds state information for a connected controller. See [[Gamepads]] for more information on handling controller input.
constructor
Returns Gamepad
publicconnected
publicevents
publicnavigatorGamepad
publicemit
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
event: GamepadEvents[TEventName]
Returns void
publicgetAxes
Gets the given axis value between -1 and 1. Values below [[MinAxisMoveThreshold]] are considered 0.
Parameters
axes: Axes
Returns number
publicgetButton
Gets the given button value between 0 and 1
Parameters
button: Buttons
Returns number
publicisButtonHeld
Tests if a certain button is held down. This is persisted between frames.
Parameters
button: Buttons
The button to query
threshold: number = 1
The threshold over which the button is considered to be pressed
Returns boolean
publicisButtonPressed
Whether or not the given button is pressed
Parameters
button: Buttons
The button to query
threshold: number = 1
The threshold over which the button is considered to be pressed
Returns boolean
publicoff
publicon
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
handler: Handler<GamepadEvents[TEventName]>
Returns Subscription
publiconce
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
handler: Handler<GamepadEvents[TEventName]>
Returns Subscription
publicupdate
Returns void
publicupdateAxes
Parameters
axesIndex: number
value: number
Returns void
publicupdateButton
Parameters
buttonIndex: number
value: number
Returns void
publicwasButtonPressed
Tests if a certain button was just pressed this frame. This is cleared at the end of the update frame.
Parameters
button: Buttons
Test whether a button was just pressed
threshold: number = 1
The threshold over which the button is considered to be pressed
Returns boolean
publicwasButtonReleased
Tests if a certain button was just released this frame. This is cleared at the end of the update frame.
Parameters
button: Buttons
Test whether a button was just released
Returns boolean
Gamepads
Excalibur leverages the HTML5 Gamepad API where it is supported to provide controller support for your games.
constructor
Returns Gamepads
publicenabled
Whether or not to poll for Gamepad input (default: false
)
publicevents
publicsupported
Whether or not Gamepad API is supported
publicstaticMinAxisMoveThreshold
The minimum value an axis has to move before considering it a change
publicat
Safely retrieves a Gamepad at a specific index and creates one if it doesn't yet exist
Parameters
index: number
Returns Gamepad
publiccount
Gets the number of connected gamepads
Returns number
publicemit
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
event: GamepadEvents[TEventName]
Returns void
publicgetValidGamepads
Returns a list of all valid gamepads that meet the minimum configuration requirement.
Returns Gamepad[]
publicinit
Returns void
publicoff
publicon
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
handler: Handler<GamepadEvents[TEventName]>
Returns Subscription
publiconce
Type parameters
- TEventName: EventKey<GamepadEvents>
Parameters
eventName: TEventName
handler: Handler<GamepadEvents[TEventName]>
Returns Subscription
publicsetMinimumGamepadConfiguration
Sets the minimum gamepad configuration, for example {axis: 4, buttons: 4} means this game requires at minimum 4 axis inputs and 4 buttons, this is not restrictive all other controllers with more axis or buttons are valid as well. If no minimum configuration is set all pads are valid.
Parameters
config: GamepadConfiguration
Returns void
publictoggleEnabled
Parameters
enabled: boolean
Returns void
publicupdate
Updates Gamepad state and publishes Gamepad events
Returns void
KeyEvent
Event thrown on a game object for a key event
constructor
publickey
The key responsible for throwing the event
publicoptionaloriginalEvent
The original keyboard event that Excalibur handled
publicother
Other target object for this event
publictarget
Target object for this event.
publicoptionalvalue
The key's typed value the browser detected
publicbubbles
If set to false, prevents event from propagating to other actors. If true it will be propagated to all actors that apply.
Returns boolean
Parameters
value: boolean
Returns void
publicstopPropagation
Prevents event from bubbling
Returns void
Keyboard
Provides keyboard support for Excalibur.
constructor
Returns Keyboard
publicevents
publicemit
Type parameters
- TEventName: EventKey<KeyEvents>
Parameters
eventName: TEventName
event: KeyEvents[TEventName]
Returns void
publicgetKeys
Gets list of keys being pressed down
Returns Keys[]
init
Initialize Keyboard event listeners
Parameters
optionalkeyboardOptions: KeyboardInitOptions
Returns void
publicisHeld
Tests if a certain key is held down. This is persisted between frames.
Parameters
key: Keys
Test whether a key is held down
Returns boolean
publicoff
publicon
Type parameters
- TEventName: EventKey<KeyEvents>
Parameters
eventName: TEventName
handler: Handler<KeyEvents[TEventName]>
Returns Subscription
publiconce
Type parameters
- TEventName: EventKey<KeyEvents>
Parameters
eventName: TEventName
handler: Handler<KeyEvents[TEventName]>
Returns Subscription
toggleEnabled
Parameters
enabled: boolean
Returns void
publictriggerEvent
Trigger a manual key event
Parameters
type: down | up
key: Keys
optionalcharacter: string
Returns void
publicupdate
Returns void
publicwasPressed
Tests if a certain key was just pressed this frame. This is cleared at the end of the update frame.
Parameters
key: Keys
Test whether a key was just pressed
Returns boolean
publicwasReleased
Tests if a certain key was just released this frame. This is cleared at the end of the update frame.
Parameters
key: Keys
Test whether a key was just released
Returns boolean
PointerComponent
Add this component to optionally configure how the pointer system detects pointer events.
By default the collider shape is used and graphics bounds is not.
If both collider shape and graphics bounds are enabled it will fire events if either or are intersecting the pointer.
constructor
Returns PointerComponent
optionalreadonlydependencies
Optionally list any component types this component depends on If the owner entity does not have these components, new components will be added to the entity
Only components with zero-arg constructors are supported as automatic component dependencies
optionalowner
Current owning [[Entity]], if any, of this component. Null if not added to any [[Entity]]
publicuseColliderShape
Use any existing Collider component geometry for pointer events. This is useful if you want
user pointer events only to trigger on the same collision geometry used in the collider component
for collision resolution. Default is true
.
publicuseGraphicsBounds
Use any existing Graphics component bounds for pointers. This is useful if you want the axis aligned
bounds around the graphic to trigger pointer events. Default is true
.
clone
Clones any properties on this component, if that property value has a
clone()
method it will be calledReturns Component
optionalonAdd
Optional callback called when a component is added to an entity
Parameters
owner: Entity<any>
Returns void
optionalonRemove
Optional callback called when a component is removed from an entity
Parameters
previousOwner: Entity<any>
Returns void
PointerEvent
constructor
Parameters
type: down | up | move | cancel
pointerId: number
button: PointerButton
pointerType: PointerType
coordinates: GlobalCoordinates
nativeEvent: Event
Returns PointerEvent
publicactive
publicbutton
publiccoordinates
publicnativeEvent
publicpointerId
publicpointerType
publictype
pagePos
Returns Vector
screenPos
Returns Vector
worldPos
Returns Vector
publiccancel
Returns void
PointerEventReceiver
The PointerEventProcessor is responsible for collecting all the events from the canvas and transforming them into GlobalCoordinates
constructor
Parameters
target: GlobalEventHandlers & EventTarget
engine: Engine<any>
Returns PointerEventReceiver
publiccurrentFrameCancel
publiccurrentFrameDown
publiccurrentFrameMove
publiccurrentFramePointerCoords
publiccurrentFramePointerDown
publiccurrentFrameUp
publiccurrentFrameWheel
publicengine
publicevents
publiclastFramePointerCoords
publiclastFramePointerDown
publicprimary
publicreadonlytarget
publicat
Locates a specific pointer by id, creates it if it doesn't exist
Parameters
index: number
Returns PointerAbstraction
publicclear
Clears the current frame event and pointer data
Returns void
publiccount
The number of pointers currently being tracked by excalibur
Returns number
publicdetach
Returns void
publicemit
Type parameters
- TEventName: EventKey<PointerEvents>
Parameters
eventName: TEventName
event: PointerEvents[TEventName]
Returns void
publicinit
Initializes the pointer event receiver so that it can start listening to native browser events.
Parameters
optionaloptions: PointerInitOptions
Returns void
publicisDown
Is the specified pointer id down this frame
Parameters
pointerId: number
Returns boolean
publicisDragEnd
Whether the Pointer just ended dragging.
Parameters
pointerId: number
Returns boolean
publicisDragStart
Whether the Pointer just started dragging.
Parameters
pointerId: number
Returns boolean
publicisDragging
Whether the Pointer is currently dragging.
Parameters
pointerId: number
Returns boolean
publicoff
publicon
Type parameters
- TEventName: EventKey<PointerEvents>
Parameters
eventName: TEventName
handler: Handler<PointerEvents[TEventName]>
Returns Subscription
publiconce
Type parameters
- TEventName: EventKey<PointerEvents>
Parameters
eventName: TEventName
handler: Handler<PointerEvents[TEventName]>
Returns Subscription
publicrecreate
Creates a new PointerEventReceiver with a new target and engine while preserving existing pointer event handlers.
Parameters
target: GlobalEventHandlers & EventTarget
engine: Engine<any>
Returns PointerEventReceiver
publictoggleEnabled
Parameters
enabled: boolean
Returns void
publictriggerEvent
Triggers an excalibur pointer event in a world space pos
Useful for testing pointers in excalibur
Parameters
type: down | up | move | cancel
pos: Vector
Returns void
publicupdate
Called internally by excalibur
Updates the current frame pointer info and emits raw pointer events
This does not emit events to entities, see PointerSystem
Returns void
publicwasDown
Was the specified pointer id down last frame
Parameters
pointerId: number
Returns boolean
PointerSystem
The PointerSystem is responsible for dispatching pointer events to entities that need them.
The PointerSystem can be optionally configured by the [[PointerComponent]], by default Entities use the [[Collider]]'s shape for pointer events.
constructor
Parameters
world: World
Returns PointerSystem
publiccurrentFrameEntityToPointers
publiclastFrameEntityToPointers
publicoverrideUseColliderShape
Optionally override component configuration for all entities
publicoverrideUseGraphicsBounds
Optionally override component configuration for all entities
publicpriority
System can execute in priority order, by default all systems are priority 0. Lower values indicated higher priority. For a system to execute before all other a lower priority value (-1 for example) must be set. For a system to execute after all other a higher priority value (10 for example) must be set.
query
publicreadonlysystemType
Determine whether the system is called in the [[SystemType.Update]] or the [[SystemType.Draw]] phase. Update is first, then Draw.
publicworld
publicaddPointerToEntity
Parameters
entity: Entity<any>
pointerId: number
Returns void
publicentered
Parameters
entity: Entity<any>
pointerId: number
Returns boolean
publicentityCurrentlyUnderPointer
Parameters
entity: Entity<any>
pointerId: number
Returns boolean
publicentityWasUnderPointer
Parameters
entity: Entity<any>
pointerId: number
Returns boolean
publicinitialize
publicleft
Parameters
entity: Entity<any>
pointerId: number
Returns boolean
optionalpostupdate
Optionally run a postupdate after the system processes matching entities
Parameters
scene: Scene<unknown>
elapsedMs: number
Time in milliseconds since the last frame
Returns void
publicpreupdate
Optionally run a preupdate before the system processes matching entities
Returns void
publicupdate
Update all entities that match this system's types
Returns void
WheelEvent
constructor
Parameters
x: number
y: number
pageX: number
pageY: number
screenX: number
screenY: number
index: number
deltaX: number
deltaY: number
deltaZ: number
deltaMode: WheelDeltaMode
ev: Event
Returns WheelEvent
publicactive
publicdeltaMode
publicdeltaX
publicdeltaY
publicdeltaZ
publicev
publicindex
publicpageX
publicpageY
publicscreenX
publicscreenY
publicx
publicy
publiccancel
Returns void
Interfaces
CapturePointerConfig
Turn on move and drag events for an [[Actor]]
captureDragEvents
Capture PointerDrag events (may be expensive!)
captureMoveEvents
Capture PointerMove events (may be expensive!)
Gamepad Axes enumeration