Discuss double input D(keyboard) to roll a long distance

well. i am coding a demo game. i want to implement roll a long distance(dodge the enemy attach) when i input double D.
My point of view:1. derived a class from UCharacterMoveComponent, and override the function of GetMaxSpeed().
like that

float UFCharacterMovementComponent::GetMaxSpeed() const
{
	float maxSpeed = Super::GetMaxSpeed();
	const AFCharacter *character = Cast<AFCharacter>(PawnOwner);
	if (character)
	{
		if (character->isSprint())
		{
			maxSpeed *= 3;
		}
	}
		
	return maxSpeed;
}

when i double click D.the maxspeed *= 3; and i use the AddMoveInput() function to sprint。
i think it’s very complex , also the code is not Inelegant。
Is a simple way to solve it?