Why do black keys have two names?
A sharp means up a half step and a flat means down a half step, so one black key can be the sharp of the note below it or the flat of the note above it. C♯ and D♭ are the same key.
Take the black key between C and D. Call it C♯ if you are thinking of C raised a half step. Call it D♭ if you are thinking of D lowered a half step. Same key, same sound.
Which name the sheet music uses depends on the key signature. A piece in D major uses C♯. A piece in A♭ major uses D♭.
You do not need to choose. Read the name on the page and press that key.
Want to practise it? Try the sharps and flats game, one minute a round.