-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document that readline.emitKeypressEvents only works when tty is in raw mode #6626
Comments
Does setting |
@addaleax Yes, it does. The event handler is called, and terminal echo turns off. |
That is expected in raw mode, yes. I am not sure whether there’s another way to make process.stdin unbuffered/return characters as they are typed… Is your question answered by this? |
Kind of. I guess the documentation should state that raw mode or a readline interface is needed. A drawback with raw mode though, is that This does not seem to work: process.stdin.on('keypress', (str, key) => {
if (key.ctrl && key.name === 'c') {
process.emit('SIGINT')
}
}) Any idea why? |
To be more clear, this is needed in raw mode process.on('SIGINT', () => {
process.exit()
}) but not when using a readline interface. |
Yeah, I guess so… The readline interface sets raw mode itself if the input is a terminal, that’s why that’s working.
If you “just” want as close to the original Ctrl+C behaviour as possible, you may want to use |
Aha, thanks! |
`readline.emitKeypressEvents` needs `stream` to be in raw mode, ref nodejs#6626
`readline.emitKeypressEvents` needs `stream` to be in raw mode. PR-URL: #6628 Fixes: #6626 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Roman Klauke <[email protected]>
uname -a
: 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64process.stdin
does not emitkeypress
afterreadline.emitKeypressEvents(process.stdin)
, but does when a readline interface created.What happens: On keypress, event handler is not called. If a readline interface is created, the event handler is called.
Expected:
stdin
to start emittingkeypress
-events.The text was updated successfully, but these errors were encountered: