Thank you for your answers. I want to keep track of the Left, Right, Up and Down keys. If I got it the right way I have to use the Readline Module? Could do that, but I think that's only a dirty workaround :(... I going to look for a/the "keypress"-module if there exist such one.
Am Mittwoch, 27. Juni 2012 17:51:18 UTC+2 schrieb Nathan Rajlich: > > The "keypress" parser was moved from the "tty" module to the "readline" > module, since that was the only place it was really being used. This means > that arbitrary Stream instances can work with the readline module by > emitting "keypress" events, but that `process.stdin` doesn't emit this > event unless it is also being used by the readline module. > > As Tim already said, put stdin in raw mode and then listen for the "data" > events. Usually you only care about Ctrl+C or Ctrl+D or Q, and those are > easy enough to detect without needed a full-blown "keypress" parser. Though > a nice user-land "keypress" module is inevitable at this point, but that's > ok because it could innovate faster than core can, and could include nice > features like mouse clicking and things like that. > > On Wed, Jun 27, 2012 at 8:23 AM, Tim Caswell <[email protected]> wrote: > >> if you set raw mode on the stdin stream, then you'll get a "data" event >> for each keystroke using the normal stream API. >> >> >> On Wed, Jun 27, 2012 at 5:06 AM, Sebi >> <[email protected]>wrote: >> >>> Hello, >>> In older versions of Node you could track keystrokes the user made >>> with the following: >>> ... >>> process.stdin.on('keypress',function(char,key) { >>> if(key && key.ctrl && key.name == "d") { >>> ... >>> } >>> } >>> ... >>> >>> In the new Version of Node the migrationwiki says the following: >>> "process.stdin.on('keypress') will not be emitted by default, as it's >>> an internal API." >>> >>> How do I enable the emitting of those events, or is there another way >>> to keep track of keystrokes? >>> >>> Hope in future this will be come back! >>> >>> >>> Regards Seb >>> >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >> >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
