After years of playing, you can do this without looking. You can hear a chord combination and just instantly know what it is. No looking involved. To a beginner it seems like magic. But take my word for it, it's not. Like anything, once you do it enough it becomes second nature.
That is the secret to the magic of music. It's only magic to those that aren't musicians. With enough practice and listening, you too will have this magic ability.
EDIT: Not that this ability is magic at all......it isn't. It's simply knowing your craft. Those that are super good at it even claim crazy things like having "perfect pitch". I don't believe in that. But I do believe in relative pitch. And I believe in peoples memory. Both of which, together, could create the illusion of perfect pitch.
I did actually meet an autistic person that did seem to have perfect pitch once. He was the only one that I ever met that passed my test of perfect pitch. My test of perfect pitch was to play 11 different notes on a piano and have the listener tell me which note I didn't play.
The only person to ever claim to have perfect pitch and pass this test was autistic. And out of many autistic savants, only one ever was right 100% of the time. No normal person ever passed.