refactor keycode to variable