Krait.js

An open source key bindings library written in TypeScript with multiple keystroke detection.

About

The purpose of this library is to provide a simple and easy to use key binding declaration.

Check Example and Code section for more information on how to use Krait.js.

You can help develop Krait.js on Github.

Example

ctrl A
Z
E
R,T

push ctrl+a, z, e, r+t keys to test.

Code

Javascript (main.js)

Instantiate a Keyboard class and creates input listeners.

var keyboard = new Krait.Keyboard();

//addInput parameters : ascii code, callback, scope
keyboard.addCommand( 'action0', 1,0,0, [65],  action0, null );
keyboard.addCommand( 'action1', 0,0,0, ['G'], action1, null );
keyboard.setInputs(  'action1', 0,0,0, ['Z'] );
keyboard.addCommand( 'action2', 0,0,0, ['E'], action2, null );
keyboard.addCommand( 'action3', 0,0,0, ['R','T'], action3, null );

function action0(){
    console.log(0);
}

function action1(){
  console.log(1);
}

function action2(){
  console.log(2);
}

function action3(){
    console.log(3);
}

Contact me

Feel free to ask me about my work, give me suggestions, or just to say hi.