Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

any docs for all nodejs event API? [closed]

I saw some code snippet like below:

process.stdin.on('keypress', function(c, key){          
if (key && 'enter' == key.name) { 

But sadly I couldn't find anything about how to use keypress event in node's docs. Obviously it's different from keypress event in browsers. Moreover there is nothing introducing what key object is, so I don't know how to use key.xxx or key.name == xxx to detect which key user is pressing.

What do I miss? There must be somewhere I can found how to use node...

like image 590
Lai Yu-Hsuan Avatar asked Sep 09 '26 21:09

Lai Yu-Hsuan


1 Answers

The node documentation seems quite lacking in that regard like you mentioned.

The only reference I found was when going through the source for the 'readline'-module:

function emitKey(stream, s) {
    var ch,
    key = {
        name: undefined,
        ctrl: false,
        meta: false,
        shift: false
    },

and so on, basically the name, if ctrl is pressed, if shift is pressed, and some meta.

There's no doubt the docs needs some work :)

like image 166
JHiller Avatar answered Sep 13 '26 00:09

JHiller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!