Simplify "key press" functions.
Add error handling to "write text" method.