Options
All
  • Public
  • Public/Protected
  • All
Menu

This Manager manages inputevents. An Object can register a callback function that is called if the corresponding key is pressed.

Hierarchy

  • BaseManager<((shift?: boolean) => void)[]>
    • InputManager

Index

Constructors

Private constructor

Properties

Private clicked

clicked: boolean

Boolean for internal use that holds if a click was started.

keys

keys: string[]

Used to show the available keys in the Manager. Mostly used for import.

Private lastpos

lastpos: Vector3

Holds the position of the mouse or touchpoint of the last frame.

lookup

lookup: {}

Represents the store of the data.

Type declaration

  • [key: string]: ((shift?: boolean) => void)[]

Private mouseclients

mouseclients: ((delta: Vector3) => void)[]

Manages all clients that need the mouse and touchevents. Calls a function that takes the delta of the last movement as parameter.

Static Private _instance

_instance: InputManager

Holds the instance of the InputManager.

Accessors

values

  • get values(): ((shift?: boolean) => void)[][]
  • Returns all saved values.

    Returns ((shift?: boolean) => void)[][]

Static Instance

  • Returns the instance of the Manager or creates a new one if there is none. Only one instance is allowed.

    Returns InputManager

Methods

add

  • add(key: string, value: ((shift?: boolean) => void)[]): void
  • Saves a value in the Manager. Overrides existing values of the key.

    Parameters

    • key: string

      The key of the value

    • value: ((shift?: boolean) => void)[]

      The value to be saved

    Returns void

addIfNotExists

  • addIfNotExists(key: string, value: ((shift?: boolean) => void)[]): void
  • Adds a value if it not already exists within the storage.

    Parameters

    • key: string

      The key of the value

    • value: ((shift?: boolean) => void)[]

      The value to be saved

    Returns void

bindEvents

  • bindEvents(canvas: HTMLCanvasElement): void
  • Binds handler to the Events of the Canvas.

    Parameters

    • canvas: HTMLCanvasElement

      Our WebGL canvas.

    Returns void

exists

  • exists(key: string): boolean
  • Checks if a key exists in the storage.

    Parameters

    • key: string

      The key to be checked.

    Returns boolean

get

  • get(key: string): ((shift?: boolean) => void)[] | undefined
  • Returns the value of a key or undefined if the key not exists.

    Parameters

    • key: string

      The key of the value to be returned.

    Returns ((shift?: boolean) => void)[] | undefined

getOrAdd

  • getOrAdd(key: string, def: ((shift?: boolean) => void)[]): ((shift?: boolean) => void)[]
  • Checks for a key and returns its value or adds the default provided.

    Parameters

    • key: string

      The key of the value to be returned.

    • def: ((shift?: boolean) => void)[]

      Defaultvalue that should be added and returned, if the key not exists.

    Returns ((shift?: boolean) => void)[]

Private handleKeypress

  • handleKeypress(event: KeyboardEvent): void
  • Triggers registered functions on a keypress.

    Parameters

    • event: KeyboardEvent

      Event to handle.

    Returns void

Private handleMouseEnd

  • handleMouseEnd(event: MouseEvent): void
  • Internal function to handle a MouseEndEvent.

    Parameters

    • event: MouseEvent

      Event to handle.

    Returns void

Private handleMouseMove

  • handleMouseMove(event: MouseEvent): void
  • Internal function to handle a MouseMoveEvent.

    Parameters

    • event: MouseEvent

      Event to handle.

    Returns void

Private handleMouseStart

  • handleMouseStart(event: MouseEvent): void
  • Internal function to handle a MouseStartEvent.

    Parameters

    • event: MouseEvent

      Event to handle.

    Returns void

Private handleTouchEnd

  • handleTouchEnd(event: TouchEvent): void
  • Internal function to handle a TouchEndEvent.

    Parameters

    • event: TouchEvent

      Event to handle.

    Returns void

Private handleTouchMove

  • handleTouchMove(event: TouchEvent): void
  • Internal function to handle a TouchMoveEvent.

    Parameters

    • event: TouchEvent

      Event to handle.

    Returns void

Private handleTouchStart

  • handleTouchStart(event: TouchEvent): void
  • Internal function to handle a TouchStartEvent.

    Parameters

    • event: TouchEvent

      Event to handle.

    Returns void

registerClick

  • registerClick(f: (delta: Vector3) => void): void
  • Allows to register a function the takes the delta of the current Drag or Touchevents.

    Parameters

    • f: (delta: Vector3) => void

      Callbackfunction for the Touch and Dragevents.

    Returns void

registerFunction

  • registerFunction(key: string, f: (shift?: boolean) => void): void
  • Allows to register a callback for a specific keypress.

    Parameters

    • key: string

      The string of the key to listen to.

    • f: (shift?: boolean) => void

      Function that should be called on Keypress.

        • (shift?: boolean): void
        • Parameters

          • Optional shift: boolean

          Returns void

    Returns void

remove

  • remove(key: string): void
  • Removes a certain key from the storage.

    Parameters

    • key: string

      The key of the value to be removed.

    Returns void

Generated using TypeDoc