extendsEventDispatcher
Base class for an input device with named buttons and axes.
On this page
Events
{
type: 'pressed',
// The button's name.
name: string
}Fired when a button goes down. The event object is reused.
{
type: 'released',
// The button's name.
name: string
}Fired when a button goes up. The event object is reused.
Properties
type: string
The kind of device: 'gamepad', 'keyboard' or 'mouse'.
connected: boolean
Whether the device is available. Always true for the keyboard and mouse.
pressThreshold: number
How far an analog button must be pressed to count as held.
releaseThreshold: number
How far a held analog button must come back to count as released.
Methods
getButtonName( name: string ): stringThe name printed on the device for a button, e.g. 'A' or 'W'.
getButtonHeld( name: string ): booleanWhether the button is down.
getButtonPressed( name: string ): booleanWhether the button went down in the last update.
getButtonReleased( name: string ): booleanWhether the button went up in the last update.
getAxis( name: string ): numberThe axis value from -1 to 1, or how far a button is pressed from 0 to 1.