Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const readline = require('readline');// https://nodejs.org/api/readline.html
- readline.emitKeypressEvents(process.stdin);//https://nodejs.org/api/readline.html#readline_readline_emitkeypressevents_stream_interface
- process.stdin.setRawMode(true);
- function showKey(str,count) {
- process.stdout.write(str+" ");
- if(count % 30 === 0) process.stdout.write("\n");
- }
- //main
- var count = 0;
- process.stdin.on('keypress', (str, key) => {
- if (key.ctrl && key.name === 'c') {
- process.exit();
- } else {
- showKey(str,count);
- count++;
- }
- });
- console.log('Press any key...');
- //notes:
- // rund node code https://npm.runkit.com/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement