Detecting CTRL+C in Node.js

前端 未结 2 1853
天命终不由人
天命终不由人 2020-12-08 01:38

I got this code from a different SO question, but node complained to use process.stdin.setRawMode instead of tty, so I changed it.

Before:

var tty =          


        
2条回答
  •  庸人自扰
    2020-12-08 02:01

    For those who need the functionality, I found death (npm nodule, hah!).

    Author also claims it works on windows:

    It's only been tested on POSIX compatible systems. Here's a nice discussion on Windows signals, apparently, this has been fixed/mapped.

    I can confirm CTRL+C works on win32 (yes, I am surprised).

提交回复
热议问题