API Docs for: 1.0.0-beta.2
Show:

layouts Module

Overview

The I-PAC 2 is a 32-input keyboard emulator manufactured by Ultimarc. It is mostly used in arcade game simulators but is also a popular way to connect switches in physical computing projects. This layout will enable you to specify bindings using the labels printed on the I-PAC 2 board (1RGHT, 2B, 1SW6, etc.). This will save you from having to look up which keycodes are triggered by which inputs.

Usage

Using it is quite simple. Simply link to the file and call the setLayout() method with the ipac2 identifier:

 <script src="tangiblekeyboard.js"></script>
 <script src="layouts/tangiblekeyboard.layout.ipac2.js"></script>

 <script>
     TangibleKeyboard.setLayout('ipac2');

     TangibleKeyboard.on(
         '1RGHT',
         {
             onKeyDown: function(e, keys, combo) { console.log(e); }
         }
     );
 </script>

That's it.

If you are using AMD or CommonJS, there's an extra step. You will need to explicitely register and assign the layout. Here's an example with AMD:

 define(function (require) {

     var tk = require('tangiblekeyboard');
     var layout = require('layouts/tangiblekeyboard.layout.ipac2');
     tk.registerAndSetLayout("ipac2", layout);

     tk.on(
         '1RGHT',
         {
             onKeyDown: function(e, keys, combo) { console.log(e); }
         }
     );

 });

Warning

The I-PAC 2 uses the MAME key mappings by default. This means that the 1STRT input actually behaves like a shift key and modifies the key assignment of other inputs when activated. It also means that this input will trigger both down and up callbacks at once when released. If you are not building a MAME-type arcade simulator, I would urge you not to use this input.