const util = require('util');
const stdin = process.stdin;
const Readable = require('stream').Readable;

const es = require('event-stream');

stdin.setRawMode(true);

stdin.resume();

stdin.setEncoding( 'utf8' );

stdin.on('data', function (key) {
  if (key === '\u0003') {
    process.exit();
  }
});

var arrowKeys = {
  '\u001b[D': {move: 'left'},
  '\u001b[A': {move: 'up'},
  '\u001b[C': {move: 'right'},
  '\u001b[B': {move: 'down'}
};

function MovementSource() {
  Readable.call(this, {objectMode: true});
  var self = this;
  this.shouldWrite = true;
  stdin.on('data', function (key) {
    if (self.shouldWrite) {
      // TODO Filter
      if (arrowKeys[key]) {
        self.shouldWrite = self.push(arrowKeys[key]);
      }
    }
  });
}

util.inherits(MovementSource, Readable);

MovementSource.prototype._read = function (bytes) {
  this.shouldWrite = true;
};

module.exports = MovementSource;

if (require.main === module) {
  (new MovementSource())
    .pipe(es.stringify())
    .pipe(process.stdout);
}


@@ -323,17 +323,17 @@
  '%5Cu001b
-%5B
+O
 D': %7Bmov
@@ -353,17 +353,17 @@
  '%5Cu001b
-%5B
+O
 A': %7Bmov
@@ -381,17 +381,17 @@
  '%5Cu001b
-%5B
+O
 C': %7Bmov
@@ -412,17 +412,17 @@
  '%5Cu001b
-%5B
+O
 B': %7Bmov
@@ -585,24 +585,65 @@
 ion (key) %7B%0A
+    // console.log(JSON.stringify(key));%0A
     if (self

Fix keystrokes.