How do I set items to unlock levels?

I am building a game where I want an item such as a key appear randomly. I have already done this. But how can I save the total number of keys collected (similar to how the high score is saved) and when a certain number is collected the next level unlocks on the main menu?

Basicaly same as your other question.
Can you just use one post please, i close this one, both are too similar.