How to rotate the model correctly

Hello. Tell me how to implement this type of movement. The character can only walk forward when the forward button is pressed. Use the arrows to rotate the model. Below is my code, but it does not work correctly. If I rotate the model, then when I press the forward button, it flies very quickly in the other direction.

Mover.prototype.rotate = function(direction){


Mover.prototype.walk = function(dt){
  const forward = this.entity.forward
  forward.z *= -0.001
  const pos = this.entity.getPosition().add(forward)