Skip to content

Instantly share code, notes, and snippets.

@newvertex
Created September 17, 2016 10:24

Revisions

  1. newvertex created this gist Sep 17, 2016.
    11 changes: 11 additions & 0 deletions KeyPressEvent.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    var readline = require('readline');

    readline.emitKeypressEvents(process.stdin);

    if (process.stdin.isTTY)
    process.stdin.setRawMode(true);

    process.stdin.on('keypress', (chunk, key) => {
    if (key && key.name == 'q')
    process.exit();
    });