The gear should be tight to the crank, not just the key.
To replace that gear the engine must be raised requiring loosening/removal of rear engine mount bolts as well as front. The radiator and pan need to be removed.
Do not drive/hammer the new gear on. I 'press' them on using various lengths of pipe made to allow the crank shaft bolt to push the gear on. Heating the gear helps.