My guess is that the browser consumes the Escape key event when unlocking the cursor so PlayCanvas never gets the event to react to.
I would either use a different key (M for example) or have some code that checks the state of the cursor lock (Mouse | PlayCanvas API Reference) every frame and when it is unlocked, (last frame was locked, current frame unlocked), show the menu UI.