const checkKeyDown = (e) => { if (e.code === 'Enter') e.preventDefault(); }; <form onSubmit={handleSubmit(onSubmit)} onKeyDown={(e) => checkKeyDown(e)}> // your steps here </form>