clean code
handle key event