Answers for "hotkeys in nodejs"

1

hotkeys in nodejs

let readline = require('readline');

readline.emitKeypressEvents(process.stdin);

process.stdin.on('keypress', (ch, key) => {
  console.log('got "keypress"', ch, key);
  if (key && key.ctrl && key.name == 'c') {
    console.log('ctrl+c was pressed');
    // do something usefull
  }
});

process.stdin.setRawMode(true);
process.stdin.resume();
Posted by: Guest on October-29-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language