How to switch scenes

can someone give me an example on a switch scene example.
like:
keyboard input function{
switch scene function
}

I think these tutorials are very helpful:
https://developer.playcanvas.com/en/tutorials/?tags=scenes

thank you but its easier for me to understand with a more direct example.

Maybe this would work

if (this.app.keyboard.isPressed(pc.KEY_SPACE)){
  //Replace newSceneName with your scene name plz
  var oldScene = this.app.root.findByName ("Root");
  var newScene = this.app.scenes.find("newSceneName").url

  oldScene.destroy()
  this.app.scenes.loadSceneHierarchy( newScene )

}

okie thx