Skip to content
/ kbd Public

node module for synchronous and asynchronous keyboard inputs, control of echo, canonical ...

Notifications You must be signed in to change notification settings

pthire/kbd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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
});

About

node module for synchronous and asynchronous keyboard inputs, control of echo, canonical ...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published