fixed bugs in some keypress events