diff options
author | DrunkenPoney <mrquebec13@gmail.com> | 2020-09-19 12:33:49 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-09-21 17:42:15 +0300 |
commit | 17ebd464ccdf12a4fb46334ff5d7a71f0f2e70a9 (patch) | |
tree | 188409a1c78ea29609f98f6e1338d8ffef974e33 /lib/internal/readline | |
parent | 98768f3b5b9db2cb384e67acd96713a6ac931df7 (diff) |
readline: fix key name for function keys with modifiers
Fixes: https://github.com/nodejs/node/issues/35251
PR-URL: https://github.com/nodejs/node/pull/35268
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/readline')
-rw-r--r-- | lib/internal/readline/utils.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index 0b9fe8cde4f..d75b64dd46b 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -199,7 +199,13 @@ function* emitKeys(stream) { // Parse the key itself switch (code) { - /* xterm/gnome ESC O letter */ + /* xterm/gnome ESC [ letter (with modifier) */ + 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 (without modifier) */ case 'OP': key.name = 'f1'; break; case 'OQ': key.name = 'f2'; break; case 'OR': key.name = 'f3'; break; @@ -296,12 +302,15 @@ function* emitKeys(stream) { } else if (ch === '\r') { // carriage return key.name = 'return'; + key.meta = escaped; } else if (ch === '\n') { // Enter, should have been called linefeed key.name = 'enter'; + key.meta = escaped; } else if (ch === '\t') { // tab key.name = 'tab'; + key.meta = escaped; } else if (ch === '\b' || ch === '\x7f') { // backspace or ctrl+h key.name = 'backspace'; |