The key with two sharps is the key of D major. In Western music, the system of keys is based on the use of scales, and each scale has a specific number of sharps or flats. The key of D major is the scale that starts on the note D and follows the pattern of whole steps (W) and half steps (H) W-W-H-W-W-W-H.

To understand why the key of D major has two sharps, it’s important to first understand what a sharp is. A sharp is a musical symbol that raises the pitch of a note by a half step. So, if a note is played with a sharp, it sounds one half step higher than the same note played without the sharp.
In the key of D major, the two notes that are sharped are F# and C#. These two sharps are necessary to maintain the pattern of the D major scale. The F# is used to maintain the whole step between the notes E and F#, and the C# is used to maintain the whole step between the notes B and C#.
One way to understand this is to look at the D major scale in more detail. The D major scale is made up of the notes D, E, F#, G, A, B, and C#. If we play this scale on a piano, we can see that there are two places where the notes are separated by a whole step. These places are between E and F# and between B and C#. In order to maintain the whole steps, we need to use the sharps on F# and C#.
Another way to understand why the key of D major has two sharps is to look at the circle of fifths. The circle of fifths is a diagram that shows the relationship between the different keys in Western music. Each key is a fifth (or seven half steps) higher than the key that comes before it in the circle. Starting from C major (which has no sharps or flats), the next key in the circle is G major, which has one sharp. The key after G major is D major, which has two sharps.
So, in summary, the key of D major has two sharps (F# and C#) because these sharps are necessary to maintain the pattern of the D major scale. Without these sharps, the whole step intervals between the notes E and F# and between B and C# would be lost. Additionally, the key of D major is the second key in the circle of fifths, which means it has one more sharp than the previous key (G major).