mscdex / node-ncurses

An ncurses binding for node.js
MIT License
385 stars 25 forks source link

HOME/END key issue #34

Open franck34 opened 11 years ago

franck34 commented 11 years ago

While running this code, we can see UP/DOWN/LEFT/RIGHT return only one key code.

But HOME/END don't have same behavior (onChar event fired multiple times, now way to catch HOME/END keys ?)

Playing with EscDelay doesn't solve the problem (i've tried 0,10,1000);

Any idea ?

var nc = require('ncurses');

// If Ctrl+C, let's clean up and exit as clean as possible
process.on('SIGINT', function() {
    nc.cleanup();
    process.exit();
});

var debugLine=1;
var debugMsg = function(msg) {
    winDebug.print(msg+'');
    debugLine++;
    winDebug.cursor(debugLine,1);
    winDebug.refresh();
}

// Draw the main window
var win = new nc.Window();

// Draw debug second window
var winDebug = new nc.Window(20,20,0,0);

winDebug.frame('Debug');
winDebug.cursor(1,1);

nc.redraw();

//nc.setEscDelay(10);

var onKey = function(chr,chrCode,isKey) {
    debugMsg(chrCode+'');
}

winDebug.on('inputChar',onKey);