Accessing specific Pawn out of PlayerController

You need to cast to your class where you got your function defined

 void AMyPlayerController::KeyPressed()
 {
         AMyCharacter* const Character = (AMyCharacter*)GetCharacter();
         Character->DoStuff();
 }

You could also add checks if GetCharacter() is indeed returning your class with if(GetCharacter()->IsA(AMyCharacter::StaticClass())) as wrong cast will crash the game, but if you 100% sure that playercontroller will use only this class then you don’t need to.