in the glacier biome, these things called coldtraps that drop the keys. i saw somewhere that the drop rate is like 33%. as for the ruin key, in the underground mudstone/ruin biomes, the ruin spirit things drop the ruin keys semi-uncommonly.