- how often does it spam, every frame?
- does the spam stop once the key is up?
- what other script is there in the widget?
- perhaps there are some bound functions?
My bet is that the issue is with something we cannot see in the screenshots. As confused as you are, especially considering:
added a print string to on focus lost to make sure that focus isn’t what’s causing it