Class: InputManager

Input.InputManager

the input manager of the engine's game object.

new Input.InputManager (canvas)

Name Type Description
canvas Canvas the canvas object (usually from the Graphics module).

Methods

getMouseEvent ()MouseEvent

get last mouse event
Returns:
Type Description
MouseEvent the mouse event

getMouseX ()Number

get mouse x position
Returns:
Type Description
Number mouse x position

getMouseY ()Number

get mouse y position
Returns:
Type Description
Number mouse y position

isKeyDown (code)Boolean

checks if a certain key is down (currently pressed)
Name Type Description
code Number key code (number)
Returns:
Type Description
Boolean true if key is pressed; false otherwise.

isKeyDownChar (c)Boolean

checks if a certain key is down (currently pressed)
Name Type Description
c String key character
Returns:
Type Description
Boolean true if key is pressed; false otherwise.

isLMBDown ()Boolean

checks if left mouse button is down
Returns:
Type Description
Boolean true if pressed; false otherwise

isMouseDown ()Boolean

checks if mouse is down (mouse button is pressed)
Returns:
Type Description
Boolean true if mouse button is pressed; false otherwise.

isRMBDown ()Boolean

checks if right mouse button is down
Returns:
Type Description
Boolean true if pressed; false otherwise

readTextFile (file)

read text file
Name Type Description
file String the file path
Returns:
file text

setOnKeyUp (callback)

register callback to key up
Name Type Description
callback function callback function(event) to be called when keyup is fired

setOnKeyUpSpec (key, callback)

register callback to key up for specific key
Name Type Description
key Number the key code of the key that fires the event
callback function callback function(event) to be called when keyup is fired with key

setOnMouseDown (callback)

register callback to mouse down
Name Type Description
callback function callback function(e) to be called when mousedown is fired.

setOnMouseUp (callback)

register callback to mouse up
Name Type Description
callback function callback function(e) to be called when mouseup is fired.