-
-
Save bgoonz/5864435b9041997efe6b14ea633871b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keypress = require('keypress'); | |
// make `process.stdin` begin emitting "keypress" events | |
keypress(process.stdin); | |
// listen for the "keypress" event | |
process.stdin.on('keypress', function (ch, key) { | |
// console.log('got "keypress"', key); | |
if(key && key.name == 'right'){ | |
console.log('right') | |
} | |
if(key && key.name == 'left'){ | |
console.log('left') | |
} | |
if(key && key.name == 'up'){ | |
console.log('up') | |
} | |
if(key && key.name == 'down'){ | |
console.log('down') | |
} | |
if (key && key.ctrl && key.name == 'c') { | |
process.stdin.pause(); | |
} | |
}); | |
process.stdin.setRawMode(true); | |
process.stdin.resume(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment