Visualizer: Extraced few func from handle_key_event()