1
0

test.js 607 B

12345678910111213141516171819202122232425262728
  1. var keypress = require('./')
  2. keypress(process.stdin)
  3. if (process.stdin.setRawMode)
  4. process.stdin.setRawMode(true)
  5. else
  6. require('tty').setRawMode(true)
  7. process.stdin.on('keypress', function (c, key) {
  8. console.log(0, c, key)
  9. if (key && key.ctrl && key.name == 'c') {
  10. process.stdin.pause()
  11. }
  12. })
  13. process.stdin.on('mousepress', function (mouse) {
  14. console.log(mouse)
  15. })
  16. keypress.enableMouse(process.stdout)
  17. process.on('exit', function () {
  18. //disable mouse on exit, so that the state is back to normal
  19. //for the terminal.
  20. keypress.disableMouse(process.stdout)
  21. })
  22. process.stdin.resume()