From 0a62f929da0cff816d79d2ed2b9b3b4ecdd50586 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 2 Apr 2016 21:08:22 -0400 Subject: [PATCH] readline: emit key info unconditionally Currently, 'keypress' events include the sequence and key info for named keys, but only the sequence for unnamed keys. This commit causes the key info to be included in both cases. PR-URL: https://github.com/nodejs/node/pull/6024 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Fedor Indutny --- lib/internal/readline.js | 5 ++--- test/parallel/test-readline-keys.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/internal/readline.js b/lib/internal/readline.js index aad0794a68..3248c7c50a 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -384,9 +384,8 @@ function* emitKeys(stream) { stream.emit('keypress', escaped ? undefined : s, key); } else if (s.length === 1) { /* Single unnamed character, e.g. "." */ - stream.emit('keypress', s); - } else { - /* Unrecognized or broken escape sequence, don't emit anything */ + stream.emit('keypress', s, key); } + /* Unrecognized or broken escape sequence, don't emit anything */ } } diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index e026c0b583..ef9e2eba90 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -48,7 +48,7 @@ function addTest(sequences, expectedKeys) { addTest('io.JS', [ { name: 'i', sequence: 'i' }, { name: 'o', sequence: 'o' }, - undefined, // emitted as `emit('keypress', '.', undefined)` + { name: undefined, sequence: '.' }, { name: 'j', sequence: 'J', shift: true }, { name: 's', sequence: 'S', shift: true }, ]);