In short, the difference between 鍵 and 鑰 is that you can safely forget the second one unless you prepare for the top level of kanji recognition test.
鍵 (on-reading: ケン) is the normal way to spell かぎ in kanji (and the only one to spell ケン "key" in compounds, such as [鍵盤]{けんばん} "keyboard"). It is a part of Jōyō list, and even the guidelines for Japanese newspapers explain that かぎ "key" is written with kanji 鍵. (Only do not confuse it with かぎ "hook," which kanji is theoretically 鉤 but it is now spelt in kana anyways, they even have the same pitch, [かぎ ]{HHL}.)
鑰 (on-reading: ヤク) is, unlike the one above, not a Jōyō kanji, or even a kanji allowed in names. It definitely exists, and is a possible way to spell かぎ, but no-one does that in modern texts, except maybe to show off. (I believe modern Chinese uses 鑰 in its words for "key" as in implement for doors, while reserving 鍵 for keys of piano.) There are some words that use 鑰 for its on-reading, but they are extremely rare.
Hence, 鍵 is your friend. Write it, and do not worry about 鑰.