Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tom32i/key-mapper.js

Simple HTML5 Input Key mapper
https://github.com/tom32i/key-mapper.js

Last synced: 21 days ago
JSON representation

Simple HTML5 Input Key mapper

Awesome Lists containing this project

README

        

key-mapper.js
=============

Simple HTML5 Input Key mapper

## Installation:

bower install --save tom32i-key-mapper.js

## Usage:

Keyboard binding:
```javascript
var mapper = new KeyboardMapper(),
listener = new InputListener(mapper, 'my-input-field');
```

Gamepad binding:
```javascript
var gamepadListener = new GamepadListener({precision: 2, deadZone: 0.3}),
mapper = new GamepadMapper(gamepadListener),
listener = new InputListener(mapper, 'my-input-field');

gamepadListener.start();
```

Gamepad specific binding:
```javascript
var gamepadListener = new GamepadListener({precision: 2, deadZone: 0.3}),
mapper = new GamepadMapper(gamepadListener, true),
listener = new InputListener(mapper, 'my-input-field');

gamepadListener.start();
```

Touch binding:
```javascript
var mapper = new TouchMapper(),
listener = new InputListener(mapper, 'my-input-field');
```

## Events:

Listen for value change on the mapping:

```javascript
mapper.on('change', function (event) {
/**
* event: CustomEvent
* detail: {
* value: 32,
* view: "Space"
* }
*/
});
```

The touch mapper return a `Touch` object as the value.