input boxes can get quite complicated actually. Especially in pygame where you have to build it from scratch. I would suggest to use existing ones or use existing ones to apply to your own. Sorry dont have time to look at yours now.
You can take a look at these for inspiration :
https://github.com/metulburr/pygooey
You can take a look at these for inspiration :
https://github.com/metulburr/pygooey
Recommended Tutorials: