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...
wankdanker committed Jan 27, 2012
1 parent 14b7c43 commit ab35fa21a6962bfe8066247131cef62d0eba7b06
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') { if (s === '\r' || s === '\n') {
// enter // enter
key.name = 'enter'; key.name = 'enter';
@@ -210,6 +212,7 @@ ReadStream.prototype._emitKey = function(s) {
key.ctrl = !!(modifier & 4); key.ctrl = !!(modifier & 4);
key.meta = !!(modifier & 10); key.meta = !!(modifier & 10);
key.shift = !!(modifier & 1); key.shift = !!(modifier & 1);
key.code = code;
// Parse the key itself // Parse the key itself
switch (code) { switch (code) {
@@ -305,6 +308,7 @@ ReadStream.prototype._emitKey = function(s) {
/* misc. */ /* misc. */
case '[Z': key.name = 'tab'; key.shift = true; break; case '[Z': key.name = 'tab'; key.shift = true; break;
default : key.name = 'undefined'; break;
} }
} else if (s.length > 1 && s[0] !== '\x1b') { } else if (s.length > 1 && s[0] !== '\x1b') {

0 comments on commit ab35fa2

Please sign in to comment.