It's very inconsistent. I've tried macros, and because of the way tf2/source works, you have to set the delay between inputs to be just perfect, if it's too fast none of them will reg, if it's too slow it won't work.
The bug itself is the same as the edgebug that is used in trickjumping, and why sometimes if you're doing a pogo in a jump map you can hit the ground and do a speedshot unintentionally, even if you should get teleported back.
My guess is that it's related to the game doing physics collision checks, and any status-based modifiers which derive from collision are done after, and valve counted on them happening on the same game tick.