make typing more reliable

I moved the actual typing into the backend thread, so the thread can check
that after every keystroke the screen changes. This is much more reliable
than blindly sleeping