Check if key pressed

In your player controller

.h file

virtual void SetupInputComponent() override;
void KeyPressed(FKey key);

.cpp

void ACarPlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();
	InputComponent->BindAction("My Action", EInputEvent::IE_Pressed, this, &YourPlayerController::KeyPressed);
}

void YourPlayerController::KeyPressed(FKey key)
{
    // do the magic
}
4 Likes