In both sentences you ask about (“Here is the key” and “Here it is”), “here” is an adverbial complement—that is, the adverb completes the predicate. The subjects of these sentences are “key” and “it.”. In the first, the subject follows the verb; in the second, the subject precedes the verb. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.