Fix keyboard race condition

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