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

Creates a DuckEngine Key

description

The Key Class. Stores info about a key's state

since

2.0.0

Hierarchy

  • Key

Index

Constructors

constructor

  • new Key(keyCode: number, descriptor: string, game: Game, scene: Scene, keyboardInput: KeyboardInput, keyDown?: (e: KeyboardEvent) => any, keyUp?: (e: KeyboardEvent) => any, keyJustPressed?: (e: KeyboardEvent) => any, keyState?: (e: KeyboardEvent, state: boolean) => any): Key
  • description

    Creates a Key instance

    since

    2.0.0

    Parameters

    • keyCode: number

      The Key keyCode

    • descriptor: string

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

    • game: Game

      Game instance

    • scene: Scene

      Scene instance

    • keyboardInput: KeyboardInput
    • 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

Properties

descriptor

descriptor: string
memberof

Key

description

The Key descriptor

since

2.0.0

game

game: Game
memberof

Key

description

Game instance

since

2.0.0

isDown

isDown: boolean
memberof

Key

description

Key down state

since

2.0.0

isJustPressed

isJustPressed: boolean
memberof

Key

description

Key just pressed state

since

2.0.0

isUp

isUp: boolean
memberof

Key

description

Key up state

since

2.0.0

keyCode

keyCode: number
memberof

Key

description

The keyCode

since

2.0.0

keyboardInput

keyboardInput: KeyboardInput
memberof

Key

description

The KeyboardInput that the key is attached to

since

2.0.0

scene

scene: Scene
memberof

Key

description

Scene instance

since

2.0.0

state

state: boolean
memberof

Key

description

Key basic state of up or down, up being false, down being true

since

2.0.0

Methods

onInput

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

    Key

    description

    Creates on event on event emitter to listen for input

    since

    2.0.0

    Parameters

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

      Callback to call on input

        • (key: Key, e: KeyboardEvent): any
        • Parameters

          • key: Key
          • e: KeyboardEvent

          Returns any

    Returns void

Protected registerListeners

  • registerListeners(): void

Generated using TypeDoc