Added keyboard support and fixed a host of bugs

Resolves #22 as well as fixing a whole plethora of issues that had not
been reported yet. Tidied up the text box system in a number of ways.