According to the Catechism (CCC 2091), the sin of despair has three forms:
- Disbelief in God’s ability to help you attain salvation.
- Belief that though God has the power to help you attain salvation, he will not help you.
- Belief that God will not forgive your sins.
You had a few moments of hopelessness but later regained hope. I can see possibly #1 applying to that situation if you for a few moments believed God will not be able to ever get you into shape to go to heaven. However, like Quaester wrote, you need deliberate consent to commit a sin, so you are culpable for no more than venial sin if you have any culpability at all.
I can’t see a quick thought here and there in desperation ever being mortal sin, let alone “unforgiveable”. Despair is only unforgiveable when the person makes one final decision to not believe in the possibility of their salvation and after that sticks to that decision the rest of their life. Anyone that turns away from despair later and regains belief in God’s power to forgive and sanctify them is no longer in that unforgiveable state. They are now receptive to God’s mercy again through confession.
I’m not sure exactly what you are dealing with, but I assure you God will make you a good enough person to overcome these sins. Just keep doing your best and going to confession. Some day you will get there. That doesn’t mean you will never commit mortal sin after that point, but it will be much more rare and less worrying. You should definitely go to confession for the mortal sins you think you committed and also ask about this despair. Your priest will be able to give a better answer.