Class Keyboard

The Keyboard class models a computer keyboard, providing ButtonInput properties for all of the keys found on most standard English computer keyboards (coverage of other language keyboards is currently unconfirmed).

Hierarchy

  • Keyboard

Implements

Constructors

  • Parameters

    • eventSubscriber: IEventSubscriber

      The passed in event subscriber should wrap around the document object, allowing the keyboard to subscribe to keyup & keydown events when the activate() method is called.

    Returns Keyboard

Accessors

  • get intlBackslash(): ButtonInput
  • ButtonInput for the Backslash `` key on non-American keyboards (typically located next to the left shift key).

    Returns ButtonInput

  • get isFinished(): boolean
  • If true, then the keyboard has been deactivated and marked for disposal.

    Returns boolean

  • get ref(): string
  • Provides a way of identifying keyboards so they can be easily retrieved later.

    Returns string

  • set ref(value: string): void
  • Parameters

    • value: string

    Returns void

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • Start listening to keyboard events.

    Returns

    Returns false if the keyboard was already activated and nothing needed to be done. Otherwise returns true.

    Returns boolean

  • Stop listening to keyboard events.

    Returns

    Returns false if the keyboard wasn't already activated and nothing needed to be done. Otherwise returns true.

    Returns boolean

  • Calling this tells the Keyboard to deactivate itself and that it will no longer be used.

    Returns void

  • This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library.

    Parameters

    • deltaMs: number

      How many milliseconds have passed since the last update cycle.

    Returns void

  • Provides a way for setting the ref through a chained function call. For example:

    clock.addChild(new Keyboard(new EventSubscriber(document)).withRef('keyboard'));
    

    Returns

    The calling object.

    Parameters

    • ref: string

      The ref to set on the object.

    Returns IClockChild

Generated using TypeDoc