update code with key events