add event handler for keypress