The target here is to be able to instantly see the "geometry" of the key, i.e. the notes of the basic scale of the key over the piano keyboard, so you don't have to "calculate". Like an imaginary reference grid overlaid on the keyboard.
At first, with total beginners, even C major which has only white keys has to be calculated, because you need to know which of the keys is C. Someone might have to resort to rules such as "C is located immediately on the left side of where you have the TWO black keys, and F is where you have the THREE black keys." But with a bit of practice it comes automatically.
The way I learned the keys was, I conquered them gradually, starting from C major / A minor (which I consider practically the same thing), and adding flats and sharps one at a time. I played songs by ear, first everything in C/Am, which made me familiar with the scale degrees and chords built on them, and special modification notes and chords such as E major, which has the G sharp. And that we can do something like B - E - Am, and during the B chord there's an additional sharp, D#. (And 30 years later I learned that this basic thing is called "secondary dominant".)
The first step away from C/Am was F/Dm. Everything is the same, except there's now one flat, because the key centers have been moved to F/D. Then I played all the songs I knew in F/Dm, until I felt comfortable with it.
The next step was to try G/Em which has one sharp. All the music and the phenomena are still exactly the same, except now the centers are G/E. Play all songs there, until comfortable.
Next, take the flat side again, but now in Bb/Gm, with two flats. Play everything in that key until it's comfortable and no need to "calculate". This was actually fairly easy, because there was only ONE added flat. So I hammered that one extra flat until it was flat.
Keep adding sharps and flats one at a time. If it takes a week to get comfortable, then that's it. If it takes a month then that's it. But eventually you'll get it done.
Every once in awhile I learned a new harmonic trick. For example, if the song is in Am, you can play a D major chord instead of the usual D minor. Ooh! Nice trick. Now, practice this trick in all keys you know.
The one thing I did not do was to try and force myself to proceed to too unfamiliar keys, until I got the previous easier phase done. Don't try to play the C minor level, until you have totally beaten the G minor boss. And don't try to play the G minor level, until you have beaten the D minor boss. Proceed along these levels, and sooner or later you're comfortable playing in all keys.