I have been following the beginner scripting tutorials, but can not get my object to move.

public class Movement : MonoBehaviour
{
    public float moveSpeed = 10f;
    void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow))
            transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
    }
}

I have been following the tutorial that teaches how to rotate and move gameobjects, and it has gotten to the point where you make the object move when a key is pressed. If I remove the if(Input.GetKey… code, it will fly away on its own. However when I add it the object does nothing, even if I press the uparrow. The same input code has worked for projects in the past.

The script you provided works. You can try with a different key, and make sure there is focus on your game area (just click on it to make sure). Also make sure, that the moveSpeed isn’t set to 0 in the inspector

Btw Vector3.forward * (moveSpeed * Time.deltaTime) will be slightly more efficient

My code is not working.

You didn’t save the changes to your script. Notice the asterisk (*) in the name at the top of Visual Studio - that indicates unsaved changes.

It also looks like your Visual Studio instance isn’t properly configured with Unity here. Follow this thread’s steps to fix that:
https://discussions.unity.com/t/778503