Just like a house's electrical wires, the heart has a system of nerves that use a constant flow of electricity to control the pumping action of the heart's muscular walls.
This keeps the heartbeat regular.