Object changing the angle of trajectory 2D,changing trajectory of an moving object 2D

So basically the object is traveling on Y axis and with the press of UpAarrow key, the trajectory will change for 45 degrees but if you press DownArrow the object will continue it’s path on the value of X that’s it’s got to. It’s 3am and I’m tired so I figured to just draw it. Also the same would go if the DOWN is pressed first, just flip the picture.

Use left & right arrow to change course of direction. Speed multiplied by Time delta so its smooth. x and y values are calculated with current z rotation.

    float speed = 3f;
    float x;
    float y;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        x = Mathf.Cos(transform.eulerAngles.z * Mathf.Deg2Rad);
        y = Mathf.Sin(transform.eulerAngles.z * Mathf.Deg2Rad);
        transform.position += new Vector3(x, y, 0) * speed * Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.LeftArrow)){
            transform.Rotate(new Vector3(0, 0, 45));
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            transform.Rotate(new Vector3(0, 0, -45));
        }
	}