Fix keypress bugs