I'm working on a blog and on the top right corner I want the user to be able to set their own display name. I have it so there's an input in place so the user can set a display name and press enter. After the user puts in a name and hits enter I want that name to be set in stone. I have everything mostly working however I'm using e.target.value which updates constantly. So if the user was named Dagger it's setting the display name to D. I want it so the name is only updated after I press enter but I can't seem to figure it out. Please advice.
const [username, setUsername] = useState("");
{username ? (
  <span className="username">{username} ▼</span>
) : (
  <form>
    <label>
      <input type="text" onChange={(e) => setUsername(e.target.value)}></input>
    </label>
  </form>
)}