Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
tty: emit 'unknown' key event if key sequence not found
Add key.code and key.sequence -mad props go out to @TooTallNate
  • Loading branch information
wankdanker authored and bnoordhuis committed Jan 28, 2012
1 parent 14b7c43 commit e4afb2f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tty.js
Expand Up @@ -154,6 +154,8 @@ ReadStream.prototype._emitKey = function(s) {
}
}

key.sequence = s;

if (s === '\r' || s === '\n') {
// enter
key.name = 'enter';
Expand Down Expand Up @@ -210,6 +212,7 @@ ReadStream.prototype._emitKey = function(s) {
key.ctrl = !!(modifier & 4);
key.meta = !!(modifier & 10);
key.shift = !!(modifier & 1);
key.code = code;

// Parse the key itself
switch (code) {
Expand Down Expand Up @@ -305,6 +308,7 @@ ReadStream.prototype._emitKey = function(s) {

/* misc. */
case '[Z': key.name = 'tab'; key.shift = true; break;
default: key.name = 'undefined'; break;

}
} else if (s.length > 1 && s[0] !== '\x1b') {
Expand Down

0 comments on commit e4afb2f

Please sign in to comment.