I'm trying to write a node.js CLI utility that periodically logs to the screen but should also allow someone to enter a key command at any time without being prompted. Something like the command bar in Vim is probably the closest analog. That said, I'm not sure where to start and don't even know what you'd call this behavior.
Don't know node-CLI, but youre probably looking for somethings what in bash could write as:
stty -echo
while :
do
read -t 1 -n 1 key
case "$key" in
'') ;; #nothing
q) stty sane; exit ;;
a|d) echo "left-right" ;;
w|s) echo "up-down" ;;
*) echo "unknown $key" ;;
esac
done
try it. (press q for exit)