Refactored onscreen keyboard. Needs tests.