handleKeyEvents