Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix meta+character keys on mac

  • Loading branch information...
commit 8da7202d0bb6a092bbdc3349840a81603ce64ccd 1 parent b9574b9
@piscisaureus piscisaureus authored ry committed
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/tty_posix.js
View
16 lib/tty_posix.js
@@ -66,6 +66,7 @@ ReadStream.prototype.isTTY = true;
Some patterns seen in terminal key escape codes, derived from combos seen
at http://www.midnight-commander.org/browser/lib/tty/key.c
+ ESC letter
ESC [ letter
ESC [ modifier letter
ESC [ 1 ; modifier letter
@@ -89,9 +90,10 @@ ReadStream.prototype.isTTY = true;
- two leading ESCs apparently mean the same as one leading ESC
*/
-// Regex used for ansi escape code splitting
-var splitKeyCodeRe =
- /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/;
+// Regexes used for ansi escape code splitting
+var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/,
+ functionKeyCodeRe =
+ /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/;
ReadStream.prototype._emitKey = function(s) {
var char,
@@ -140,7 +142,13 @@ ReadStream.prototype._emitKey = function(s) {
key.name = s.toLowerCase();
key.shift = true;
- } else if (parts = splitKeyCodeRe.exec(s)) {
+ } else if (parts = metaKeyCodeRe.exec(s)) {
+ // meta+character key
+ key.name = parts[1].toLowerCase();
+ key.meta = true;
+ key.shift = /^[A-Z]$/.test(parts[1]);
+
+ } else if (parts = functionKeyCodeRe.exec(s)) {
// ansi escape sequence
// reassemble the key code leaving out leading \x1b's,
Please sign in to comment.
Something went wrong with that request. Please try again.