〜拍子に・〜はずみで
the moment (and by accident), as a result of (a sudden movement)
Verb た-form + 拍子に / はずみで · 何かの拍子に
Sign up free to review this point on a spaced schedule.
拍子に says that at the moment of one sudden action, something else happened by accident: 転んだ拍子に、眼鏡が落ちた, "when I fell over, my glasses came off".
The first half is usually an abrupt physical movement (falling, standing up, sneezing, bumping into something), and the second half is an unintended result. はずみで (弾みで) means the same, and はずみに is also used.
何かの拍子に means "for some reason or other, by chance": 何かの拍子に、昔のことを思い出す, "every now and then, something makes me remember the past".
It's close to たとたん (N3), but 拍子に stresses the accidental knock-on effect. 拍子 means "rhythm, beat", as in the beat that triggers the next thing.
Examples
転んだ拍子に、眼鏡が落ちた。
When I fell over, my glasses came off.
立ち上がった拍子に、頭をぶつけた。
I banged my head as I stood up.
くしゃみをした拍子に、腰を痛めた。
I hurt my back when I sneezed.
何かの拍子に、昔のことを思い出す。
Every now and then, something makes me remember the past.
人とぶつかったはずみで、コップが割れた。
I bumped into someone and the glass broke.