Skip to content

Input.js

dannyx0 edited this page Aug 10, 2012 · 2 revisions

Input.js captures three basic input events (touchstart/mousedown, touchmove/mousemove, touchend/mouseup) and provides simple function hooks. Each function passes two parameters, average (an averaged x/y object) and inputs (an array of all inputs).

Options

element			[dom]	-	DOM element to track input on.
preventDefault	[bool]	-	Should default event behavior be prevented?

Quick Start

HTML

<div id="target"></div>

JavaScript

require(["Input"], function (input) {

	input.init({
		element : document.getElementById('target'),
		preventDefault : true
	});

	input.ontapstart = function (average) {
		console.log(average.x, average.y);
	};

	input.ontapmove = function (average) {
		console.log(average.x, average.y);
	};

	input.ontapend = function (average) {
		console.log(average.x, average.y);
	};

});

Clone this wiki locally