Rotate an object 90 degrees

Hi, so I am making a game where I want to be able to rotate my object 90 degrees instantly when pressing an arrow key. I already got the arrow key down but not the rotation 90 degrees. Whenever I tell it to rotate 90% it just goes acts really glitchy and rotates 180 degrees, and I can’t use Time.deltaTime because it then does not rotate 90 degrees instantly and instead you have to hold down the button. Idk if this helps but the object is always moving. Thanks for all the help!

I wasn’t sure if these are the axis you want the object to rotate around but you can easily change that. Just attach this script on the object you want to rotate in void Update and it should work. If you have any further questions feel free to message me.

if (Input.GetKeyDown (KeyCode.LeftArrow)){
transform.Rotate (0, -90, 0);
}else if (Input.GetKeyDown (KeyCode.RightArrow)){
transform.Rotate (0, 90, 0);
}else if (Input.GetKeyDown (KeyCode.UpArrow)){
transform.Rotate (90, 0, 0);
}else if (Input.GetKeyDown (KeyCode.DownArrow)){
transform.Rotate (-90, 0, 0);