Pixeljs

A simple and flexible HTML5 and JavaScript powered game engine.

View Project on GitHub Download Pixel.js (v0.9b)

Engine.on Method

Hooks a function to the specified event.

Parameters

Name Description
event The name of the event to bind the callback to.
callback The function to invoke when the event occurs.

Remarks

The events currently supported by the on method are:

  • keyDown(keyCode): occurs when the user presses a key down.
  • keyUp(keyCode): occurs when the user releases a key press.
  • mouseup(point, button): occurs when the user releases a mouse button.
  • mousedown(point, button): occurs when the user presses a mouse button.
  • mousemove(point): occurs when the user moves the mouse.

Multiple event handlers can be assigned to a single event if desired.

Examples

Supported Platforms

Google Chrome, Mozilla FireFox, Internet Explorer 9+, Opera, Safari.