You’re on the right track.
First up, whilst BindKey is valid, you might find BindAction to be more convinient when it comes to allowing custom controller setups, or when deciding you want to change which key / button performs the action (with a binding, just change it in the editor rather than having to find each case). Obviously it’s your choice and there are ways of achieving whatever you want with both methods, so go with whatever you like (it’s fairly trivial to change later down the line if needed).
So, taking your example:
InputComponent->BindKey(EKeys::A, IE_Released, this, &Controller::AReleased);
This will perform an action when the A key is released. You can change to IE_Pressed (I think) to perform some action when the key is pressed. Having one binding for pressed and another for release makes it easy to control things like ‘hold shift to run’.
The fourth param in your binding has some issues though. You need to replace &Controller with the name of your class where the bound mthod can be found. In your case it looks like &AtestcodingprojectCharacter. You then need to provide a method name. I’d suggest &AtestcodingprojectCharacter::OnSprintReleased. You can also use &ThisClass::OnSprintReleased.
Next up you need to actually create your OnAReleased method. In your .h file make a new protected or private method (it can be public, but nothing else should ever really call this method so best to protect it)
UFUNCTION()
void OnSprintReleased();
Now in your cpp, implement that method
void AtestcodingprojectCharacter::OnSprintReleased()
{
//your code in here
}
Hopefully that’s set you up with the binding events.
To toggle a sprint you should make another binding but using IE_Pressed and a new method OnSprintPressed.
Now you have your two methods you can either use a bool to track the state (which you just set to true or false in the methods you just created), but my prefered way would be to directly set the movement speed, thereby avoiding any tick processing. Something like:
GetCharacterMovement()->MaxWalkSpeed = whatever_you_want_the_speed_to_be;
Just have one of them in the OnSprintPressed and another in OnSprintReleased. Ideally you’d have the two desired speeds setup as editable, but hardcoding for now will get you going.