mirror of https://github.com/nodejs/node.git
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 <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>pull/6024/merge
parent
3de9bc9429
commit
0a62f929da
|
@ -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 */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 },
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue