Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine KeyboardInput

description

The KeyboardInput Class. Use the Keyboard as input

since

2.0.0

Hierarchy

  • KeyboardInput

Index

Constructors

constructor

Properties

eventEmitter

eventEmitter: EventEmitter
memberof

KeyboardInput

description

The EventEmitter used to emit for Key events

since

2.0.0

game

game: Game
memberof

KeyboardInput

description

Game instance

since

2.0.0

keys

keys: {}
memberof

KeyboardInput

description

All of the Keys added to the KeyboardInput

since

2.0.0

Type declaration

  • [key: string]: Key

scene

scene: Scene
memberof

KeyboardInput

description

Scene instance

since

2.0.0

Accessors

inputs

  • get inputs(): {}

Methods

addKey

  • addKey(keyCode: number, descriptor: string, keyDown?: (e: KeyboardEvent) => any, keyUp?: (e: KeyboardEvent) => any, keyJustPressed?: (e: KeyboardEvent) => any, keyState?: (e: KeyboardEvent, state: boolean) => any): Key
  • memberof

    KeyboardInput

    description

    Adds a Key to the KeyboardInput

    since

    2.0.0

    Parameters

    • keyCode: number

      The Key keyCode

    • descriptor: string

      The Key descriptor, used to set the value to KeyboardInput.keys

    • Optional keyDown: (e: KeyboardEvent) => any
        • (e: KeyboardEvent): any
        • Parameters

          • e: KeyboardEvent

          Returns any

    • Optional keyUp: (e: KeyboardEvent) => any
        • (e: KeyboardEvent): any
        • Parameters

          • e: KeyboardEvent

          Returns any

    • Optional keyJustPressed: (e: KeyboardEvent) => any
        • (e: KeyboardEvent): any
        • Parameters

          • e: KeyboardEvent

          Returns any

    • Optional keyState: (e: KeyboardEvent, state: boolean) => any
        • (e: KeyboardEvent, state: boolean): any
        • Parameters

          • e: KeyboardEvent
          • state: boolean

          Returns any

    Returns Key

addKeys

  • memberof

    KeyboardInput

    description

    Adds a Key to the KeyboardInput

    since

    2.0.0

    Parameters

    • keys: KeyBase[]

      An array of base key configurations to create Keys from

    Returns void

onInput

  • onInput(cb: (key: Key, e: KeyboardEvent) => any): void
  • memberof

    KeyboardInput

    description

    Adds an onInput event listener to all keys

    since

    2.0.0

    Parameters

    • cb: (key: Key, e: KeyboardEvent) => any
        • (key: Key, e: KeyboardEvent): any
        • Parameters

          • key: Key
          • e: KeyboardEvent

          Returns any

    Returns void

removeKey

  • removeKey(descriptor: string): void
  • memberof

    KeyboardInput

    description

    Removes a Key from the KeyboardInput

    since

    2.0.0

    Parameters

    • descriptor: string

      Key descriptor

    Returns void

Generated using TypeDoc