pull-keys

Pull stream for UI keydown events

pull-keys

A pull-stream for keydown events, using vkey key-codes. Saw keydown and thought this might be a good idea too.

For any key presses:

var pull = require('pull-stream');
var pk = require('pull-keys');
 
pull(
  pk(),
  pull.log()
);
 

Or define, a key map:

var pull = require('pull-stream');
var pk = require('pull-keys');
 
pull(
  pk({
    left: '<left>',
    right: true,
    selectAll: ['<control>', 'a']
  }),
  pull.log()
);
 

Additionally, you can do some clever things by using a keymap to map key combinations to taskify tasks:

var pull = require('pull-stream');
var pk = require('pull-keys');
var task = require('taskify')();
 
task('selectAll', function() {
  console.log('need to select all');
});
 
// task up depends on select all 
task('up', ['selectAll'], function() {
  console.log('need to move up');
});
 
// map commands to tasks 
pull(
  pk({
    selectAll: ['<control>', 'a'],
    up: '<up>',
    right: true
  }),
//   pull.log() 
  pull.drain(task.exec)
);
 

Copyright (c) 2015, Damon Oehlman damon.oehlman@gmail.com

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.