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 backquote(): ButtonInput
  • ButtonInput for the Backquote ` key.

    Returns ButtonInput

  • get backslash(): ButtonInput
  • ButtonInput for the Backslash `` key.

    Returns ButtonInput

  • get backspace(): ButtonInput
  • ButtonInput for the Backspace key in the numbers row.

    Returns ButtonInput

  • get buttons(): ButtonInput[]
  • The collection of all ButtonInputs that the Keyboard holds.

    Returns ButtonInput[]

  • get capslock(): ButtonInput
  • ButtonInput for the Caps Lock key.

    Returns ButtonInput

  • get equal(): ButtonInput
  • ButtonInput for the Equal key in the numbers row.

    Returns ButtonInput

  • 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 leftBracket(): ButtonInput
  • ButtonInput for the Left Bracket [ key.

    Returns ButtonInput

  • get leftCtrl(): ButtonInput
  • ButtonInput for the Left Control key.

    Returns ButtonInput

  • get leftShift(): ButtonInput
  • ButtonInput for the Left Shift key.

    Returns ButtonInput

  • get minus(): ButtonInput
  • ButtonInput for the Minus key in the numbers row.

    Returns ButtonInput

  • get numpad0(): ButtonInput
  • ButtonInput for the 0 key in the numpad.

    Returns ButtonInput

  • get numpad1(): ButtonInput
  • ButtonInput for the 1 key in the numpad.

    Returns ButtonInput

  • get numpad2(): ButtonInput
  • ButtonInput for the 2 key in the numpad.

    Returns ButtonInput

  • get numpad3(): ButtonInput
  • ButtonInput for the 3 key in the numpad.

    Returns ButtonInput

  • get numpad4(): ButtonInput
  • ButtonInput for the 4 key in the numpad.

    Returns ButtonInput

  • get numpad5(): ButtonInput
  • ButtonInput for the 5 key in the numpad.

    Returns ButtonInput

  • get numpad6(): ButtonInput
  • ButtonInput for the 6 key in the numpad.

    Returns ButtonInput

  • get numpad7(): ButtonInput
  • ButtonInput for the 7 key in the numpad.

    Returns ButtonInput

  • get numpad8(): ButtonInput
  • ButtonInput for the 8 key in the numpad.

    Returns ButtonInput

  • get numpad9(): ButtonInput
  • ButtonInput for the 9 key in the numpad.

    Returns ButtonInput

  • get numpadAdd(): ButtonInput
  • ButtonInput for the Add + key in the numpad.

    Returns ButtonInput

  • get numpadDecimal(): ButtonInput
  • ButtonInput for the Decimal . key in the numpad.

    Returns ButtonInput

  • get numpadDivide(): ButtonInput
  • ButtonInput for the Divide / key in the numpad.

    Returns ButtonInput

  • get numpadEnter(): ButtonInput
  • ButtonInput for the Enter key in the numpad.

    Returns ButtonInput

  • get numpadMultiply(): ButtonInput
  • ButtonInput for the Multiply * key in the numpad.

    Returns ButtonInput

  • get numpadSubtract(): ButtonInput
  • ButtonInput for the Subtract - key in the numpad.

    Returns ButtonInput

  • get numrow0(): ButtonInput
  • ButtonInput for the 0 key in the numbers row.

    Returns ButtonInput

  • get numrow1(): ButtonInput
  • ButtonInput for the 1 key in the numbers row.

    Returns ButtonInput

  • get numrow2(): ButtonInput
  • ButtonInput for the 2 key in the numbers row.

    Returns ButtonInput

  • get numrow3(): ButtonInput
  • ButtonInput for the 3 key in the numbers row.

    Returns ButtonInput

  • get numrow4(): ButtonInput
  • ButtonInput for the 4 key in the numbers row.

    Returns ButtonInput

  • get numrow5(): ButtonInput
  • ButtonInput for the 5 key in the numbers row.

    Returns ButtonInput

  • get numrow6(): ButtonInput
  • ButtonInput for the 6 key in the numbers row.

    Returns ButtonInput

  • get numrow7(): ButtonInput
  • ButtonInput for the 7 key in the numbers row.

    Returns ButtonInput

  • get numrow8(): ButtonInput
  • ButtonInput for the 8 key in the numbers row.

    Returns ButtonInput

  • get numrow9(): ButtonInput
  • ButtonInput for the 9 key in the numbers row.

    Returns ButtonInput

  • get pageDown(): ButtonInput
  • ButtonInput for the Page Down key.

    Returns ButtonInput

  • 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 rightAlt(): ButtonInput
  • ButtonInput for the Right Alt key.

    Returns ButtonInput

  • get rightBracket(): ButtonInput
  • ButtonInput for the Right Bracket ] key.

    Returns ButtonInput

  • get rightCtrl(): ButtonInput
  • ButtonInput for the Right Control key.

    Returns ButtonInput

  • get rightShift(): ButtonInput
  • ButtonInput for the Right Shift key.

    Returns ButtonInput

  • get semicolon(): ButtonInput
  • ButtonInput for the Semicolon ; key.

    Returns ButtonInput

  • 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