Fix keyboard race condition

After typing, the keyboard does not instantly appear. Wait for it to apepar, and
then dismiss the keyboard.