Added event handler to wait for key press