I am using Nodejs the readline module what I am trying to do is when the user inputs a letter. The key they input I want to straight away have that key(letter) to be returned like as if it was the enter key being pressed but still be the key(letter) they pressed.
On the code below I have the prompt asking the user to put in w, a, s or d So i wanted these 4 keys to be returned right away on the click and if they put any other key have the terminal ignore it and not show it at all how do I do that?
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
/// the function is below
function userInput(input) {
input = readline.question('Please move\n (w for up)\n (a for left)\n (s for down)\n (d for right)',
theMove => {
console.log(`Nice move ${theMove}!`);
readline.close();
});
userInput();