Fixed some bugs an added keypress events