The answer to this question boils down to how authentic you want your piano-playing experience to be.
On the surface, there really isn’t much difference between an acoustic piano, a digital piano, and any of the multitude of music keyboards and synthesizers.
This means it’s possible to play the same notes on both a piano and a keyboard.
However, all instruments vary in how they feel and how they respond to a player’s touch.
Acoustic and digital pianos often have heavier keys which are weighted more heavily at the lower end (left-hand side) of the keyboard and have a lighter touch at the top end (right-hand side). Most standard keyboards and synthesizers do not have this.
Additionally, nothing can completely rival a true acoustic piano in terms of sound. High-end digital pianos come close. Every digital instrument is only giving an approximation of the sound of an acoustic piano.
Cheaper instruments, and those for whom a realistic piano sound is not a priority (such as some synthesizers which are more geared to creating non-acoustic sounds) may not offer all the nuances and subtleties you’d expect from an acoustic piano or a very good digital piano.
However, the average musician and listener may never notice the difference. A seasoned classical or jazz pianist might do, but could still use a digital piano or keyboard from time to time for convenience.
It’s also worth considering that most pianos have at least 76 keys on their keyboard, and usually 88 keys, whereas some keyboards and synths have 49 or 61 keys (four or five octaves). This means that some pieces of music which have a wide range might be very difficult to play seamlessly.
So yes, you can play piano notes on a keyboard but you should be aware of its possible limitations.