For example, for this piece, how can I tell whether it's in D major or other keys by just listening to it. And is there any systematic way to do so? Thanks!
Unless you have absolute pitch, not really. While it would be cool to do so it isn’t a terribly useful skill since anytime you really need to identify a key of a song you probably have access to an instrument. Most people use a musical instrument to determine the key.
The easiest way, which works in many but not all cases, is to identify resting chord. That is the chord the piece tends to feel ‘at Home’ on.
One could sit with a guitar or piano and listen for a while till they can tell when that chord comes and the play different chords on the instrument until it matches up.
It is possible to get good enough at this to identify the key of a simple piece in seconds.
Another way might be to identify groups of chords, like cadences. That usually tells you the key more reliably that just listening for one chord. It still isn’t perfect, but using the above two techniques it is pretty likely that one could get the key of pretty much any song very quickly.
The final technique might be to identify all the chords and do some theory analysis. But again by the time you get to the second point you usually have the key.