extracting keyhandling method in CodeSlide