Rotate an object by 90degrees with GetKeyDown?

I know it’s a silly simple thing, but I’m very new and would like to play with this little feature :slight_smile:

What I’d like to do is rotate my character’s Y rotation by 90 degrees when pressing e and rotate it -90 degrees when pressing q.

I have this at the moment, which isn’t really working.

var rotation = 90.0;
 
function Update () {
    if (Input.GetKeyDown ("e")) {
        rotation += 90;
        transform.Rotate (0,rotation,0 * Time.deltaTime);
    }
}

Please help!

Try :

function Update () {
    if (Input.GetKeyDown ("e")) {
        transform.Rotate (transform.rotation.x,transform.rotation.y+90,transform.rotation.z);
    }
    else if (Input.GetKeyDown ("q")) {
        transform.Rotate (transform.rotation.x,transform.rotation.y-90,transform.rotation.z);
    }
}