On most instruments, including the piano, economy of movement is important. What is the least movement you can use, to get the sound you desire? Because using the least movement possible, is the least fatiguing, and by not wasting movement, you have the opportunity to play faster figures when you want to.
On a piano, the only variable (ignoring pedals) that affects the sound coming from the strings, is the velocity of the hammer when it strikes the string. The only influence you have on this, is the velocity of the key at a certain moment in its travel.
It's likely that you can achieve that velocity without letting go of the key -- but whatever feels comfortable is likely to be best for you.
However a piano is a percussion instrument, which means it's all about getting hit. And to get certain sounds, you need to hit it hard! And to hit it hard you may need to lift your hand some distance to give it some attack. It all depends on whether you want to sound like Little Richard or Richard Clayderman! (Or, less dramatically, whether you're playing the strident first movement, or the lyrical Adagio, from Grieg's piano concerto).
It will also depend on the piano. Some pianos give you a long travel during which your finger and the key can gain velocity, others have less. Some pianos offer more resistance than others.
Use your ears. If it makes the sound you want, you're doing the right thing.