Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides keyboard support for Excalibur.

Hierarchy

Index

Constructors

Properties

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

Methods

  • emit(eventName: string, eventObject: any): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • init(global?: GlobalEventHandlers): void
  • Initialize Keyboard event listeners

    Parameters

    • Optional global: GlobalEventHandlers

    Returns void

  • isHeld(key: Keys): boolean
  • 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

  • off(eventName: string, handler?: (event: any) => void): void
  • Alias for removeEventListener. If only the eventName is specified it will remove all handlers registered for that specific event. If the eventName and the handler instance are specified only that handler will be removed.

    Parameters

    • eventName: string

      Name of the event to listen for

    • Optional handler: (event: any) => void

      Event handler for the thrown event

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • on(eventName: "press", handler: (event: KeyEvent) => void): void
  • on(eventName: "release", handler: (event: KeyEvent) => void): void
  • on(eventName: "hold", handler: (event: KeyEvent) => void): void
  • on(eventName: string, handler: (event: Events.GameEvent<any, any>) => void): void
  • once(eventName: string, handler: (event: any) => void): void
  • Once listens to an event one time, then unsubscribes from that event

    Parameters

    • eventName: string

      The name of the event to subscribe to once

    • handler: (event: any) => void

      The handler of the event that will be auto unsubscribed

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    Returns void

  • triggerEvent(type: "up" | "down", key: Keys, character?: string): void
  • Trigger a manual key event

    Parameters

    • type: "up" | "down"
    • key: Keys
    • Optional character: string

    Returns void

  • update(): void
  • wasPressed(key: Keys): boolean
  • 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

  • wasReleased(key: Keys): boolean
  • 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