title: Nodejs, read from /dev/input/event* right way
body: <p>I have code like this and have strange effect, 
  if there are more then 3 devices opened,
  it doesnt work properly.</p>
  
  <p>i have the same functional in python with select polling
  and it works good.</p>
  
  <p>please say "where is my BAD ?"</p>
  
  <pre><code>var fs = require("fs"),
    path = require("path");
  
  function is_device(device_path) {
          return (
              device_path.indexOf("event") &gt;= 0 &amp;&amp; 
              fs.statSync(device_path).isCharacterDevice()
          );
      }
  
      function list_devices(base_dir) {
          return fs.readdirSync(base_dir).map(function(device){
              return path.join(base_dir, device);
          }).filter(is_device);
      }
  
  
      var chunks = [];
  
  
      function read_devices(base_dir) {
          // if we slice return of list_devices to 3
          // it will be work good and many dots we can see....
          var devices =  list_devices(base_dir).map(function(device_name){
              try {
                  return fs.createReadStream(device_name, {
                      flags: 'r',
                      encoding: null
                  })
                  .on('readable', function(){
                      this.read(16);
                      process.stdout.write('.');
                  });
              } catch(e){
                  return null;
              }
          });
          return devices.filter(function(device){return device != null;});
      }
  
      var device_streams = read_devices("/dev/input/");
  </code></pre>