Mice hate naphthalene which mothballs do contain but the mothballs do not contain enough of the naphthalene to deter mice so using mothballs will not keep mice away.
You'd need a stronger dose of naphthalene in the mothballs if you want to keep mice away.
You can repel mice by using the scent of peppermint though since mice hate the scent of peppermint and will avoid any area that peppermint scent is coming from.
To keep mice completely away and out of your house you need to set traps or put out mouse poison too and get rid of the mice so they don't come into your home and damage things or eat your food.