Question: I would like to be able to play a piano or keyboard and have what I play stored and reproduced as musical notation. Is that possible?

Answer: 
As others have mentioned a MIDI keyboard and notation application that understands MIDI is what you need.

But, two other important things to mention...

* You probably want to check whether/or how the notation application handles rhythm and *quantizing*, which is a kind of rhythmic precision in the capture of your playing. Even if a person plays with very, very good timing an unquantized rhythm will look crazy with dotted rhythms, ties, 64th notes, etc. Quantizing can do something like move rhythms to the closest sixteenth note, depending on the settings used.
* You will likely need to do some manual editing of the captured notation to do things like correct a rhythm, change an accidental, etc. Depending on what you're playing and the software you will probably need to deal with key signatures, meters, staves, etc. If you don't know how to notate music, you won't know how to proof read and correct the capture.

Software can help speed up the process of notation, but it can't substitute for not knowing how to notate music.
This is very feasible, and has been for a long time. You need three things:

1. First a keyboard that captures the pressing down of keys. Today you would probably select a midi keyboard with USB connection. You may check this website to get an overview what is available in the market. [Example of large webshop to get an overview of what is available, not a recommendation](https://www.thomann.de/se/midi_masterkeyboards.html)
2. Secondly you need a computer. Most computers made the last ten years or even more will do. (And mouse, screen). Internet connection helps.
3. The third part is a program that can do the translation. All of the three "professional" programs does this (Finale, Sibelius, Dorico). At least one of them has a free version (Dorico SE) which you simply download.The free program Musescore is another example that can do it. There are quite a few other programs available that can do similar things, almost all so called DAW-s can do it. (And I have probably forgotten a dozen or more programs).

My general experience is that it can take a bit of work to create a good looking score from my fumbling on the keyboard, but that is me.