I am making a basic todo list with React and right now, it works when I press a button with text in the text field. I am trying to make it work so when I press enter on the input field, it also works. The function itself works when I press the button, I just want some sort of "onEnter" instead of "onClick" to submit the field as well. Here is what I have right now...
import React, { useState, useEffect } from 'react'
function handleSubmit(event) {
// event logic here, code already works.
// takes the text in the input field and adds to list
// works on button press.
}
export function TodoInput() {
return (
<div>
<input onSubmit={handleSubmit} id="todoInput" type="text" />
<button className="submitButton" onClick={handleSubmit}>Add to Todo</button>
</div>
)
}