added some key event and element visibility management