Added delay to loop waiting for key.