One of the biggest concerns people have when they meet me is whether they can keep their house if they file bankruptcy. Fortunately the answer is usually "Yes, if ..."
The "if" part of the answer is that if you have a mortgage against your home you will, in any ordinary case, have to keep paying it. If you have equity in your home, we can protect up to $450,000.00 of equity ("value minus mortgage balance") (more for farmers) and up to 160 acres in size, so it is unlikely that the trustee will try to take your home.
Now, sometimes, if you have two mortgages and if the first mortgage is more than the total value of the house, we can get rid of the second mortgage in a chapter 13. And if you are behind on payments when you file bankruptcy, we can catch up in a chapter 13. And on three occasions during my career I've run into a mortgage that's not valid because it was a refinance of a homestead and only the husband signed the mortgage.
Other than that sort of situation, who will take your home is your mortgage company if you don't pay them. As a practical matter the mortgage company may stop sending you statements, so you will have to push the payments from your end rather than having the company pull it from your end.
But if you are current on your home mortgage when your case is filed, "all" you have to do is to stay current.