phoboslab/Ejecta — pull request #123 by SRandazzo (2013-02-22 21:08:18+00:00)
Title: Add native Key-Input and keyboard controls

This allows you to create `KeyInput` objects capable of pulling up, dismissing and getting key input from the keyboard.

You can also add eventListeners for when the input object has lost focus and gained focus (`keyboardToggled` = true or false)

I chose an object based approach as opposed to a global, singular input approach so that you have the option of scoping/attaching input objects to individual objects. And if you don't, then you can just use one globally.

Interface is as follows:

```JavaScript

var keyInput = new Ejecta.KeyInput();

//open the keyboard
keyInput.open();

//Lets you set if you want singular key strokes, vs chunked text (in the case of pasting for example you get more than a single character)
//default == true
keyInput.sendChunkedInput = true;

//listen for key strokes, passed in as strings.
keyInput.addEventListener( 'keyInput', function( event ) {
console.log('key pressed!');
console.log(event);

//close the keyboard
keyInput.close();
}, false);

keyInput.addEventListener( 'toggleKeyboard', function(e){
console.log('keyboard opened or closed for this keyInput object');
}, false);

//Check if keyboard is currently open for this keyInput object
if (keyInput.isOpen()) {
console.log('keyboard is open for this keyInput object');
}

```

Let me know if you see any other useful things we could add to this.

thanks!