Search code examples
stdinttykeystroke

Listen to stream from /dev/tty where return key is not necessary


Is there a way to read a stream from /dev/tty, and make it unnecessary to hit the return key to send data there? I want to be able to type a character and have it sent without hitting return/enter.


Solution

  • Just a matter of using raw mode, at least with Node.js:

    const {ReadStream} = require('stream');
    const r = new ReadStream();
    r.setRawMode(true);