phaser - v4.0.0-rc.4
    Preparing search index...

    A generic Key object which can be passed to the Process functions (and so on) keycode must be an integer

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    altKey: boolean

    The down state of the ALT key, if pressed at the same time as this key.

    ctrlKey: boolean

    The down state of the CTRL key, if pressed at the same time as this key.

    duration: number

    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.

    emitOnRepeat: boolean

    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.

    enabled: boolean

    Can this Key be processed?

    isDown: boolean

    The "down" state of the key. This will remain true for as long as the keyboard thinks this key is held down.

    isUp: boolean

    The "up" state of the key. This will remain true for as long as the keyboard thinks this key is up.

    keyCode: number

    The keycode of this key.

    location: number

    The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad.

    metaKey: boolean

    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.

    originalEvent: KeyboardEvent

    The original DOM event.

    The Keyboard Plugin instance that owns this Key object.

    repeats: number

    If a key is held down this holds down the number of times the key has 'repeated'.

    shiftKey: boolean

    The down state of the SHIFT key, if pressed at the same time as this key.

    timeDown: number

    The timestamp when the key was last pressed down.

    timeUp: number

    The timestamp when the key was last released.

    Methods

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

    • Calls each of the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • ...args: any[]

        Additional arguments that will be passed to the event handler.

      Returns boolean

    • Returns the duration, in ms, that the Key has been held down for.

      If the key is not currently down it will return zero.

      To get the duration the Key was held down for in the previous up-down cycle, use the Key.duration property value instead.

      Returns number

    • Return the number of listeners listening to a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns number

    • Return the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns Function[]

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

    • Add a one-time listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

    • Processes the Key Down action for this Key. Called automatically by the Keyboard Plugin.

      Parameters

      • event: KeyboardEvent

        The native DOM Keyboard event.

      Returns void

    • Processes the Key Up action for this Key. Called automatically by the Keyboard Plugin.

      Parameters

      • event: KeyboardEvent

        The native DOM Keyboard event.

      Returns void

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

    • Resets this Key object back to its default un-pressed state.

      As of version 3.60.0 it no longer resets the enabled or preventDefault flags.

      Returns this

    • 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

      • value: boolean

        Emit down events on repeated key down actions, or just once?

      Returns this