The piano is a musical instrument which is played by means of a keyboard. In comparison to the violin, saxophone, flute, and many other instruments, the piano is capable of producing both the melody and the accompaniment. If you wish to play modern hip hop, R&B, rap, club, techno, and other non-classical songs, the piano is capable of producing the bass-like effect as well, it's all in your mind. Basically, the piano is capable of producing any sound, from the honk of trucks on the road, noise from the vacuum cleaner, rap, and much more. Just use your imagination. That is the most important skill to learn if you wish to play by ear, your imagination.
Think of the piano as a tool for you to express yourself. Like a sword if you're a warrior, like a gun if you're a shooter, like a pen if you're a scholar. There are 88 keys on a typical full-sized piano. Do not limit your imagination by thinking that the lower part has to be the accompaniment and upper should be melody. You can use it both ways, reverse, opposite, mixed, matched, crazy stuffs, anything! Before you play, you first need to recognize the keys. If you look at the piano, you see both black and white keys, am I right? The white keys are called natural notes, whereas the black ones are known as sharp or flats. We usually start with the note middle C, almost in the middle, the 40th key of a 88 keys full sized keyboard / piano. If you notice, the black keys comes in two group and three group, which simply means two black notes and three black notes. The middle C is located in the middle of the piano, on the left of the first black note of two black notes. Just refer to the illustration below:
Now just use your ears to slowly identify and recognize these notes. Compare it to your favorite song, find the bass or the melody. Personally, I do the bass first because it's easier to follow, just follow the beat with your heart. C'mon, I know you can do it! Just believe in your ability. You need to learn this in order to learn how to play by ear.
Let's stop here for now before I confuse you even further. This is already slightly technical. You can do it!