Matthew (Chapter 2) simply states that Jesus was born in Bethlehem and they fled to Egypt. Luke (Chapter 2) says they journeyed to Bethlehem. Neither mentions a moce of transportation. I suspect they walked. I think it unlikely they were rich enough to afford a donkey.
Note also in Acts. Nowhere does it state that Paul was riding a horse when he confronted Jesus. Again, I think he was walking.