Skip to content

Commit

Permalink
Extended Esc sequences for iTerm2 and Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Feb 28, 2022
1 parent 6151138 commit cee518b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ function emitKeys(stream, s) {

// Parse the key itself
switch (code) {
/* iTerm2 ESC [ letter */
case '[P': key.name = 'f1'; break;
case '[Q': key.name = 'f2'; break;
case '[R': key.name = 'f3'; break;
case '[S': key.name = 'f4'; break;

/* xterm/gnome ESC O letter */
case 'OP': key.name = 'f1'; break;
case 'OQ': key.name = 'f2'; break;
Expand Down Expand Up @@ -237,6 +243,18 @@ function emitKeys(stream, s) {
case '[23~': key.name = 'f11'; break;
case '[24~': key.name = 'f12'; break;

/* Windows */
case '[25~': key.name = 'f3'; key.shift = true; break;
case '[26~': key.name = 'f4'; key.shift = true; break;
case '[28~': key.name = 'f5'; key.shift = true; break;
case '[29~': key.name = 'f6'; key.shift = true; break;
case '[31~': key.name = 'f7'; key.shift = true; break;
case '[32~': key.name = 'f8'; key.shift = true; break;
case '[33~': key.name = 'f9'; key.shift = true; break;
case '[34~': key.name = 'f10'; key.shift = true; break;
case '[23$': key.name = 'f11'; key.shift = true; break;
case '[24$': key.name = 'f12'; key.shift = true; break;

/* xterm ESC [ letter */
case '[A': key.name = 'up'; break;
case '[B': key.name = 'down'; break;
Expand Down

0 comments on commit cee518b

Please sign in to comment.