Phaser Press Any Key to Continue
A generic Key object which can be passed to the Process functions (and so on) keycode must be an integer
Constructor:
new Key(plugin, keyCode) Parameters:
Extends
- Phaser.Events.EventEmitter
Members
altKey: boolean
Description:
The down state of the ALT key, if pressed at the same time as this key.
Default: false
ctrlKey: boolean
Description:
The down state of the CTRL key, if pressed at the same time as this key.
Default: false
duration: number
Description:
The number of milliseconds this key was held down for in the previous down - up sequence. This value isn't updated every game step, only when the Key changes state. To get the current duration use the getDuration method.
Default: 0
emitOnRepeat: boolean
Description:
When a key is held down should it continuously fire the down event each time it repeats?
By default it will emit the down event just once, but if you wish to receive the event for each repeat as well, enable this property.
Default: false
enabled: boolean
Description:
Can this Key be processed?
Default: true
isDown: boolean
Description:
The "down" state of the key. This will remain true for as long as the keyboard thinks this key is held down.
Default: false
isUp: boolean
Description:
The "up" state of the key. This will remain true for as long as the keyboard thinks this key is up.
Default: true
keyCode: number
Description:
The keycode of this key.
location: number
Description:
The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad.
Default: 0
metaKey: boolean
Description:
The down state of the Meta key, if pressed at the same time as this key. On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key.
Default: false
originalEvent: KeyboardEvent
Description:
The original DOM event.
Description:
The Keyboard Plugin instance that owns this Key object.
Type:
repeats: number
Description:
If a key is held down this holds down the number of times the key has 'repeated'.
Default: 0
shiftKey: boolean
Description:
The down state of the SHIFT key, if pressed at the same time as this key.
Default: false
timeDown: number
Description:
The timestamp when the key was last pressed down.
Default: 0
timeUp: number
Description:
The timestamp when the key was last released.
Default: 0
Methods
addListener(event, fn, [context])
Description:
Add a listener for a given event.
Parameters:
| name | type | arguments | Default | description |
|---|---|---|---|---|
| event | string | symbol | The event name. | ||
| fn | function | The listener function. | ||
| context | * | <optional> | this | The context to invoke the listener with. |
Returns:
destroy()
Description:
Removes any bound event handlers and removes local references.
emit(event, [args])
Description:
Calls each of the listeners registered for a given event.
Parameters:
| name | type | arguments | description |
|---|---|---|---|
| event | string | symbol | The event name. | |
| args | * | <optional> | Additional arguments that will be passed to the event handler. |
Returns:
Description:
true if the event had listeners, else false.
eventNames()
Description:
Return an array listing the events for which the emitter has registered listeners.
Type:
- Array.<(string
- symbol)>
getDuration()
Description:
Returns the duration, in ms, that the Key has been held down for.
If the key is not currently down it will return zero.
The get the duration the Key was held down for in the previous up-down cycle, use the Key.duration property value instead.
Returns:
Description:
The duration, in ms, that the Key has been held down for if currently down.
listenerCount(event)
Description:
Return the number of listeners listening to a given event.
Parameters:
| name | type | description |
|---|---|---|
| event | string | symbol | The event name. |
Returns:
Description:
The number of listeners.
listeners(event)
Description:
Return the listeners registered for a given event.
Parameters:
| name | type | description |
|---|---|---|
| event | string | symbol | The event name. |
Returns:
Description:
The registered listeners.
off(event, [fn], [context], [once])
Description:
Remove the listeners of a given event.
Parameters:
| name | type | arguments | description |
|---|---|---|---|
| event | string | symbol | The event name. | |
| fn | function | <optional> | Only remove the listeners that match this function. |
| context | * | <optional> | Only remove the listeners that have this context. |
| once | boolean | <optional> | Only remove one-time listeners. |
Returns:
on(event, fn, [context])
Description:
Add a listener for a given event.
Parameters:
| name | type | arguments | Default | description |
|---|---|---|---|---|
| event | string | symbol | The event name. | ||
| fn | function | The listener function. | ||
| context | * | <optional> | this | The context to invoke the listener with. |
Returns:
onDown(event)
Description:
Processes the Key Down action for this Key. Called automatically by the Keyboard Plugin.
Parameters:
| name | type | description |
|---|---|---|
| event | KeyboardEvent | The native DOM Keyboard event. |
onUp(event)
Description:
Processes the Key Up action for this Key. Called automatically by the Keyboard Plugin.
Parameters:
| name | type | description |
|---|---|---|
| event | KeyboardEvent | The native DOM Keyboard event. |
once(event, fn, [context])
Description:
Add a one-time listener for a given event.
Parameters:
| name | type | arguments | Default | description |
|---|---|---|---|---|
| event | string | symbol | The event name. | ||
| fn | function | The listener function. | ||
| context | * | <optional> | this | The context to invoke the listener with. |
Returns:
removeAllListeners([event])
Description:
Remove all listeners, or those of the specified event.
Parameters:
| name | type | arguments | description |
|---|---|---|---|
| event | string | symbol | <optional> | The event name. |
Returns:
removeListener(event, [fn], [context], [once])
Description:
Remove the listeners of a given event.
Parameters:
| name | type | arguments | description |
|---|---|---|---|
| event | string | symbol | The event name. | |
| fn | function | <optional> | Only remove the listeners that match this function. |
| context | * | <optional> | Only remove the listeners that have this context. |
| once | boolean | <optional> | Only remove one-time listeners. |
Returns:
reset()
Description:
Resets this Key object back to its default un-pressed state.
Returns:
Description:
This Key instance.
setEmitOnRepeat(value)
Description:
Controls if this Key will continuously emit a down event while being held down (true), or emit the event just once, on first press, and then skip future events (false).
Parameters:
| name | type | description |
|---|---|---|
| value | boolean | Emit |
Returns:
Description:
This Key instance.
shutdown()
Description:
Removes all listeners.
Source: https://newdocs.phaser.io/docs/3.54.0/Phaser.Input.Keyboard.Key
0 Response to "Phaser Press Any Key to Continue"
Post a Comment