How old does a child have to be to decide to live with their grandparents?

Although a minor's input MAY be asked by the judge, in the end it is the court who decides who the primary custodial parent will be. The child has very little input on the decision.