microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.46k stars 235 forks source link

How to send CTRL + c #521

Closed frmdeveloper closed 2 years ago

frmdeveloper commented 2 years ago

Environment details

Issue description

How to send CTRL + c I'm confused

Tyriar commented 2 years ago

pty.write('\x3') should do it

frmdeveloper commented 2 years ago

$ node

root@railway:~# node
Welcome to Node.js v14.18.2.
Type ".help" for more information.
> 

> pty.write("\x3")

Execution Function:1
pty.write("\x3")
             ^
ParseError: Bad character escape sequence

SyntaxError: Invalid hexadecimal escape sequence
    at Object.exports.chatupdate (/root/frmdev/index.js:3151:54)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
3rror404 commented 2 years ago

@frmdeveloper pty.write("\003") works (on MacOS at least)

Tyriar commented 2 years ago

My mistake, '\003', '\x03' or '\u0003' is the right syntax.