Reads raw terminal input sequences, then translates them into key codes and state flags.