Ducking 2 clubs then playing the 4th club is necessary, declarers hand being QTx x AQJxx KQxx. If you, say, duck 2 clubs, win the 3rd and play a heart, declarer can now ruff a heart, ruff a club, ruff a heart, and play the SQ out of his hand, ducking your K. You are now endplayed into leading a spade into his Tx.
If you play the 4th club, declarer has no entry to strip the 3rd heart, so you are ok.
In real life, easily one of the strongest declarers in the world played this way against me. After 2 rounds of trumps, he should have played ace of hearts, heart ruff, and then clubs himself and he would be ok (retaining an entry to his hand with the trump so if clubs are 3-3, he's ok, and if clubs are 4-2 he has this line available to him). I think declarer just thought clubs would be 3-3 when I had 3 diamonds, RHO might well bid 3H if he had 6 hearts and 1 diamond, and he could easily falsecard the heart count since the bidding marks declarer with a stiff. And if hearts are 1-6, LHO still rates to be 4333 since that is a more likely takeout X shape.
Anyways, the point is, he misplayed slightly and didn't cater to an unlikely layout, he did not make the STRONGEST play, and that gives you a chance. Ducking the club should just be a matter of technique (and if you don't, declarer has an extra entry to strip out the hand again), but many people would just win the CK with the ace without thinking. Then, it looks like your play of a heart or a club doesn't matter, but a club is the only play to beat them.
Don't feel bad if you got this wrong, I inexplicably got this double dummy position wrong at the table. Declarer did not err after that, he played me for KJx of spades since that hand is more likely to make a t/o X than Kxx.
My teammate at the other table played correctly and started to strip it out after 2 rounds of trumps, so this was a push and a missed opportunity. My teammate who hates t/o Xs such as this informed me that this hand has no play without a X