It's the taper that holds the flywheel on, the key is just to locate it wheres it supposed to be on the shaft. If it's coming loose you have taper problems not key problems. Those here who work in factories know that taper shafts (drills, lathes etc) just push in with your hand yet need a wedge and hammer to remove them again.
Sometimes hours of lapping is required to match the tapers again after damage has occured or idiots that put them on with rubbish on the shaft or flywheel.
Don't forget after lapping to remove the lip that you create on the fat end of the crank taper - this lip is often a source of trouble on a damaged/worn taper as people think the flywheel is tight but it's just butted up against that lip and still not secure on the taper.