For context this is the whole sentence. "動いた拍子に,立て掛けて置いた刀が倒れかけ慌てて押さえた.".
"立て掛けて置いた刀が倒れかけ慌てて押さえた" I know that the gist of this part is that a sword was placed against something and fell over. But I need some help with the meaning of "動いた拍子に" this part. I know from this "動" kanjj that it's talking about movement but I am unsure of how to translate the rest of it.