Only send keys when a key is pressed

Also fix race condition in (linux) launch script