Fix #3648: improved reliability of keyboard access in ios

Add some redundancy to offset Instruments' flaky behavior when locating the foremost app and keyboard.