When did muskets get invented?

Roughly 1000 years ago. Time was so long ago hat we have no exact records.