InputManager

InputManager

The input manager is a view-side service with the public name "InputManager". It captures common UI events and turns them into Croquet events that you can subscribe to. If you want to use the input manager, add it as a service to your root view.

class MyViewRoot extends ViewRoot {
     static viewServices() { return [InputManager];}
}

Extends

  • ViewService

Members

# inFullscreen :boolean

Returns true if the app is currently in fullscreen mode

Type:
  • boolean

# inPointerLock :boolean

Returns true if the app is currently in pointerlock mode. In pointerlock mode the mouse cursor will not be displayed and mouse movements will not return screen coordinates.

Type:
  • boolean

Methods

# addChord(name, down, upopt)

Adds a custom event that will fire when a combination of keys is pressed. The event chordDown is published when the chord is completed, and the event chordUp is published when any key in a pressed chord is released.

Parameters:
Name Type Attributes Description
name string

The name of the chord.

down Array.<string>

The keys that comprise the chord.

up Array.<string> <optional>

The keys that prevent the chord.

Example
this.service("InputManager").addChord("cheat", ['q', 't']); // Pressing q and t together will start cheat mode
this.subscribe("input", "cheatDown", () => { console.log("Start cheat mode!"); })

# enterFullscreen()

Attempts to put the app in fullscreen mode.

# exitFullscreen()

Takes the app out of fullscreen mode.

Note: Many browsers provide alternate ways to cancel fullscreen.

# enterPointerLock()

Attempts to put the app in pointerlock mode. In pointerlock mode the mouse cursor will not be displayed and mouse movements will not return screen coordinates.

# exitPointerLock()

Takes the app out of pointerlock mode. In pointerlock mode the mouse cursor will not be displayed and mouse movements will not return screen coordinates.

Note: Many browsers provide alternate ways to cancel pointerlock.