fixed bugs and add keydown event for enter key