Mold keys are used to align and register the multiple parts of a mold, ensuring they fit back together accurately and produce castings with minimal flashing. They work by creating matching positive (protruding) and negative (recessed) shapes on the parting line of the mold halves, such as indentations, ridges, or tongues and grooves.