replaced KeyListener code with KeyStroke for better performance