I feel a bit stupid for answering my own question...
But after some more research on Google, I found this, where you can scroll down to New key progression system you'll find some information, that perfectly answers my question:
Think of the scores as percentages: an S is worth 50%, an A is worth 40%, all the way down to 10% for a D. So an SS is worth 100%, an SA is worth 90%, etc.
Your top scores in each level are combined to determine your key count: every 100 percentage points you earn, you get a key. For example, if you get an AB (70%) on one level, and a SA (90%) on another, you get a key, and the 60% remainder is applied to your next key.
This works on a per-key-type basis. So you have a separate meter for silver keys, gold keys, etc.