How to use/retrieve APlayerController [noob question]

First of all im a complete newbie and I basically dont know what the f I am doing in my life.
So yeah basically I want to check whether a key is being pressed/was pressed.

I was planning on using
APlayerController::IsInputKeyDown (EKeys::Key);
but I dont know how to get the current ‘APlayerController’.

Hey,

If your doing singleplayer only, I believe its something like this

()->GetFirstPlayerController()

Or I believe
UGameplayStatics::GetPlayerController((), 0);

With any world action you should double check its valid first so I would guess -

if (())
{
     UGameplayStatics::GetPlayerController((), 0);
}

Update: Oh and just a handy tip if your new to C++. Get a copy of Unreal source code from github or just have github open on the UE page. If you want a function like getInput, run a search on github for that, and you can check how epic implement it. This is basically how I do all my coding.

GetController() from pawn possessed by that controller or from any actor ()->GetFirstPlayerController(); but that works well only in single player.