Simplify movement and fix bug in keypress event handler.