You can configure Node to listen for key events, this will parse those into a nice record.
If the input is an ansi command, return the command portion, with the escape code removed.