Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeyboardHandler

Represents a global keyboard. Will likely only create one per app.

You can bind/switch KeyboardContexts to the Keyboard handler to change input 'modes'.

Hierarchy

  • KeyboardHandler

Index

Constructors

constructor

  • new KeyboardHandler(config?: undefined | { stopPropagation: boolean }): KeyboardHandler

Methods

clearContext

isKeyDown

  • isKeyDown(keyCode: number): boolean
  • Returns if a key is currently held down.

    Parameters

    • keyCode: number

      KeyCode | number - The keyCode to check

    Returns boolean

setContext

waitForKeyDown

  • waitForKeyDown(keyCode?: undefined | number): Promise<number>
  • Returns a promise that will resolve the next time a given keyCode is pressed down. If no keyCode is given, it will return the next keyCode pressed.

    Parameters

    • Optional keyCode: undefined | number

    Returns Promise<number>

    • The pressed keyCode.

waitForKeyUp

  • waitForKeyUp(keyCode?: undefined | number): Promise<number>
  • Returns a promise that will resolve the next time a given keyCode is released. If no keyCode is given, it will return the next keyCode released.

    Parameters

    • Optional keyCode: undefined | number

      The keyCode to listen to. If not provided, will monitor for any keycode.

    Returns Promise<number>

    • The pressed keyCode.

Generated using TypeDoc