Skip to content

6a. Input ‐ handlers

CookieShade edited this page Jul 16, 2016 · 5 revisions

Input handling

Becuase the old DOM is terrible, and the new DOM is terribly supported, BETA.js provides a different way to handle input.

BETA.initInput()

Starts up the input handling system. The rest of the input functions won't work without calling this first.

BETA.isButtonDown(button)

Returns whether a button is currently held down.

BETA.onButtonDown(button, callback)

Calls a function whenever a given button is pressed. Ignores repeat button-press events fired when a key is held down.

BETA.onButtonUp(button, callback)

Calls a function whenever a given button is pressed.

BETA.getMousePos(renderer)

Gets the current mouse position, relative to a canvas renderers top-left corner, in pixels. Note: May not work correctly if the underlying element has had its CSS attributes (e.g. border) modified.

Clone this wiki locally