Changed the handling of keypresses to be a wee bit more sane.