How to check if a key is Up/Down?

float result = InputComponent->GetAxisKeyValue(EKeys::A);
if ( result){
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT(“This is an on screen message!”));
}

What am I doing wrong? I tried many keys, none worked.

Axis keys are “keys” such as the sticks on the gamepad and you can get the current axis value for them as seen by that particular InputComponent.using GetAxisKeyValue.

The input component doesn’t actually track whether it thinks a given key is down or not. Your best option is PlayerController->IsInputKeyDown(EKeys::A) which looks at the global state of whether that physical key is currently down (as far as the PlayerInput is concerned, if you were to press it while the application didn’t have focus and then alt-tab it would most likely report as false).

2 Likes