0.1.0 • Published 10 years ago

kbd v0.1.0

Weekly downloads
2
License
BSD
Repository
github
Last release
10 years ago

#kbd

kbd module provides various utilities for keyboard. I wanted to have a node equivalent for printf, scanf, puts, gets for my students to whom I teach programming with node. kdb provides these functions in both synchrone and asynchrone mode. kdb also gives the opportunity to set/unset echo, set unset canonical mode.

This version is completely rewritten with "nan" (Native Abstraction for Node.js). Sorry for any bad english ;-)

var kbd = require('kbd');
// synchronously reads one line from keyboard

var line = kbd.getLineSync();
// asynchronously reads one line from keyboard

kbd.getLine(function (error, line) {
    // line variable contains keyboard entered line
};
// synchronously reads one key from keyboard in non canonical mode without echo

kbd.setEcho(false);             // no echo mode
kbd.setCanonical(false);        // non canonical mode
var char = kbd.getKeySync();
kbd.setEcho(true);              // reestablish echo mode
kbd.setCanonical(true);         // reestablish canonical mode
// asynchronously reads key from keyboard in non canonical mode without echo

kbd.setEcho(false);             // no echo mode
kbd.setCanonical(false);        // non canonical mode
kbd.getKey(function (error, key) {
    // key variable contains pressed key
    // dont forget to reset echo and canonical mode before the end of script
    // if you forgot, type shell 'reset' command
    kbd.setEcho(true);              // reestablish echo mode
    kbd.setCanonical(true);         // reestablish canonical mode
});
0.1.0

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

11 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago