blessed icon indicating copy to clipboard operation
blessed copied to clipboard

keypressed incompatiable with Nodemon

Open stockholmux opened this issue 8 years ago • 3 comments

If running a script that uses blessed executed by nodemon, the key presses will only register after hitting enter/return.

screen.on('keypress', function(ch, key){ console.log(key); });

If you type 'asdf' then you won't see any of the key press logs, but if you press enter/return, you'll see the long for 'a', then 's', then 'd', then 'f' and finally return all at the same time.

Running the same script with plain 'node', the behaviour will be as expected.

stockholmux avatar Feb 23 '18 12:02 stockholmux

Nodemon likely uses a readline style input (or buffers input) for optimisation. If this is a case, this is intended behaviour and is caused by nodemon, not blessed.

TapGhoul avatar Feb 23 '18 15:02 TapGhoul

I had this problem as well, and it was a bit unclear on how to solve it when consulting the Nodemon documentation. Seems like it's not even in the docs.

But it's actually easy to solve, just pass the following flag to Nodemon when firing it up: -I, --no-stdin

For over clarification: nodemon -I your_blessed_program_now_working.js

Then all your $TERM (xterm etc) escape sequences will work as usual, and Nodemon will re-execute your program when you write any changes to the file.

jimpsson avatar Apr 15 '18 13:04 jimpsson

I had this problem as well, and it was a bit unclear on how to solve it when consulting the Nodemon documentation. Seems like it's not even in the docs.

But it's actually easy to solve, just pass the following flag to Nodemon when firing it up: -I, --no-stdin

For over clarification: nodemon -I your_blessed_program_now_working.js

Then all your $TERM (xterm etc) escape sequences will work as usual, and Nodemon will re-execute your program when you write any changes to the file.

if add the -I option, ctrl-c won't response after the first restarting

fatfatson avatar Jun 07 '19 02:06 fatfatson