fixed key simulation to write to stdout