|
@ -122,27 +122,31 @@ ReadStream.prototype._emitKey = function(s) { |
|
|
// tab
|
|
|
// tab
|
|
|
key.name = 'tab'; |
|
|
key.name = 'tab'; |
|
|
|
|
|
|
|
|
} else if (s === '\b' || s === '\x7f') { |
|
|
} else if (s === '\b' || s === '\x7f' || |
|
|
|
|
|
s === '\x1b\x7f' || s === '\x1b\b') { |
|
|
// backspace or ctrl+h
|
|
|
// backspace or ctrl+h
|
|
|
key.name = 'backspace'; |
|
|
key.name = 'backspace'; |
|
|
|
|
|
key.meta = (s.charAt(0) === '\x1b'); |
|
|
|
|
|
|
|
|
} else if (s === '\x1b') { |
|
|
} else if (s === '\x1b' || s === '\x1b\x1b') { |
|
|
// escape key
|
|
|
// escape key
|
|
|
key.name = 'escape'; |
|
|
key.name = 'escape'; |
|
|
|
|
|
key.meta = (s.length === 2); |
|
|
|
|
|
|
|
|
} else if (s === ' ') { |
|
|
} else if (s === ' ' || s === '\x1b ') { |
|
|
key.name = 'space'; |
|
|
key.name = 'space'; |
|
|
|
|
|
key.meta = (s.length === 2); |
|
|
|
|
|
|
|
|
} else if (s <= '\x1a') { |
|
|
} else if (s <= '\x1a') { |
|
|
// ctrl+letter
|
|
|
// ctrl+letter
|
|
|
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1); |
|
|
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1); |
|
|
key.ctrl = true; |
|
|
key.ctrl = true; |
|
|
|
|
|
|
|
|
} else if (s >= 'a' && s <= 'z') { |
|
|
} else if (s.length === 1 && s >= 'a' && s <= 'z') { |
|
|
// lowercase letter
|
|
|
// lowercase letter
|
|
|
key.name = s; |
|
|
key.name = s; |
|
|
|
|
|
|
|
|
} else if (s >= 'A' && s <= 'Z') { |
|
|
} else if (s.length === 1 && s >= 'A' && s <= 'Z') { |
|
|
// shift+letter
|
|
|
// shift+letter
|
|
|
key.name = s.toLowerCase(); |
|
|
key.name = s.toLowerCase(); |
|
|
key.shift = true; |
|
|
key.shift = true; |
|
@ -254,7 +258,13 @@ 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; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} else if (s.length > 1 && s[0] !== '\x1b') { |
|
|
|
|
|
// Got a longer-than-one string of characters.
|
|
|
|
|
|
// Probably a paste, since it wasn't a control sequence.
|
|
|
|
|
|
Array.prototype.forEach.call(s, this._emitKey, this); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Don't emit a key if no name was found
|
|
|
// Don't emit a key if no name was found
|
|
|