Hw does a digital piano work?
Piano sound generation is complicated by the sound being so familiar to most of us, and the slowly decaying non-stationary non-harmonic nature of overtones meaning that simple attack + looped samples is hard to get right. It is simplified by the low dimensionality of user interaction (88 keys with velocity, 3 pedals) compared to, say, a guitar where there are many dimensions to how the string is picked and how your left hand interacts with the string.
It used to be that digital pianos used synthesis in order to produce tones. My old Roland piano used «SA synthesis»:
http://www.novelmusic.com/roland/Technical/default.htm
As digital memory has become cheaper, my impression is that nowadays, digital piano generation is mostly PCM samples recorded in multiple key (-zones) and multiple strike velocities, with a minimum of resynthesis to smooth things out. I might be wrong.
https://en.m.wikipedia.org/wiki/Inharmonicity