That getIRKey routine blocks waiting for a key to be pressed. Thus the led stays on until you press another.