What I would do is take that Singleton logic called SceneHandler.tscn or something of that order.
Then have a function called changescene(scenepath)
From there when you do your on levels key pressed():
SceneHandler.change_scene(res://..)
What may be happening is when you call a change scene from within the same scene, it can kill your current one and you are left with a gap of logic. Basically you want an always running Singleton in the background that controls it all and will never stop running through your games lifecycle.
I hope this was helpful and the article I sent was helpful in the previous post. Please do tell me if it wasn’t or if it needs more details and I’m happy to update it. I’m trying to build some good resources for people working with Godot!
Hopefully more tutorials to come ;) and I hope this helped you