Edited the OP to format the code.
I think you might want to move it out of _process()
(into input processing perhaps?) and make sure the CanvasLayer node has it's respective pause state set to such that it can continue to work when the game is paused.
Currently your code pauses the game when the menu is brought up but then it stops processing on the next frame update since the game is paused.