The #1 criterion considered by the judge determining the attribution of a child’s custody is the best interest of the child. The stability of the child, in the context of rupture, is therefore important: its environment, room, school, friends, etc.
1) If you are thinking about leaving your home with your children on a whim, be aware that you could instead apply for an order from the Court authorizing you to remain in the family home instead of your (ex) spouse, and so , preserve the stability of the child and avoid disorganization.
2) Think before you leave de facto custody of children to the other spouse at the time of breakup, believing that this will not impact any of your custody rights at the end of the process. The Court may consider that the situation of children with your spouse is stable and therefore favour the maintenance of this situation.
To know your rights, it is better to consult a lawyer before or shortly after a breakup.