Repository navigation
Readline keypress event is triggered only after pressing Esc key 3 times #7379
Description
Activity
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.readlineIssues and PRs related to the built-in readline module.Issues and PRs related to the built-in readline module.
on Jun 23, 2016 I've dug into this a bit and can confirm the bug exists in
v4.xandv5.xIt would appear to have been introduced in
v2.0.2I'll dig into that release and see where it came fromSo it would appear that escape started acting weird after aed6bce906 landed.
Doesn't appear to be easily revertable... I'm digging into what is going on with escape
Found the offending section
https://github.com/nodejs/node/blob/master/lib/internal/readline.js#L144-L151
The original PR introduced this logic which yields to more results if the first character is an escape... which is problematic if your entire payload is an escape. It allows for double escaped characters, which is why things work on the third press
Not sure the best way to approach this, but I'll revisit in the morning
@thealphanerd It was mentioned in the PR itself.
@princejwesley sigh... I wish I had read the pr instead of just the commit and then digging into the code.
@cjihrig you have the blame on most of
internal/readline.jswould you specify this as awont-fixrather than as a bug?@thealphanerd I'll fix it!
Reacted by Myles Borins3 remaining items
@cjihrig I accepted that drawback as the primary use of esc in a terminal is to start an escape sequence, but I now see the issue with applications relying on that key.
@princejwesley I guess a timeout-based approach to triggering the key is the way to go. I just don't know if 700ms is the correct value, seems a tad high.
@silverwind
Default timeout values forzshis400msand for vim & ncurses, its1sec. @sindresorhus suggested to kepp the middle value between400 - 1000. Shall I update with the middle value of '400 - 700' (550ms) or400ms? One second is too high.How about 500ms, like in GNU readline (http://man7.org/linux/man-pages/man3/readline.3.html)?
Reacted by Prince John Wesley@silverwind Done
- added a commit that references this issue
on Aug 13, 2016 - added a commit that references this issue
on Aug 20, 2016 - added a commit that references this issue
on Sep 30, 2016 This has been backported to v4.x in 68a2979
- added a commit that references this issue
on Oct 18, 2016 - added a commit that references this issue
on Oct 26, 2016 - added a commit that references this issue
on Jul 27, 2026
Test case
Expected
After pressing Esc once, I would get this output:
Actual
After pressing Esc three times, I get this output:
It works fine on 0.10.44 and 0.12.13. After pressing Esc once:
Also notice that
metaisfalsehere.