Permalink
Browse files

tty: emit 'uknown' key event if key sequence not found

tty: add key.code and key.sequence
	-mad props go out to @TooTallNate
  • Loading branch information...
1 parent 14b7c43 commit ab35fa21a6962bfe8066247131cef62d0eba7b06 @wankdanker committed Jan 27, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/tty.js
View
@@ -154,6 +154,8 @@ ReadStream.prototype._emitKey = function(s) {
}
}
+ key.sequence = s;
+
if (s === '\r' || s === '\n') {
// enter
key.name = 'enter';
@@ -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) {
@@ -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') {

0 comments on commit ab35fa2

Please sign in to comment.