How can I make a Key Press Event happen in code?

Hi guys !

I’m doing an item pick up system and I was using the Bluprint event system.

Right now I’m doing everything through script except this : EditorKeyPressed(FKey Key, EInputEvent Event)

this works well … During the editor. But when I play obviously it doesn’t work.

So I want to know if there’s something equal for ingame event.

My actor inherit from AActor.

1 Like

Try using WasInputKeyJustPressed, which is a function in the APlayerController class.

if (yourPlayerController->WasInputKeyJustPressed(EKeys::B))
	// do something

Hi Chris, Thank you for your quick answer.

This is not what i’m trying to do.

Basically I used this with Blueprint and what I want to do is implement the “OnKeyPressed” in my current Actor.

This way after the
ReceiveActorBeginOverlap(class AActor* Other)

I enable the EnableInput(MyPC);

And then I want to do the same thing as I do with Blueprint : KeyEvent : E but through script

Alright guys I found a way to do it :

I enable the Tick function :
Tick(float DeltaTime)

if (!bCanTick)

if (currentPlayerController != NULL)
	if (currentPlayerController->WasInputKeyJustPressed(EKeys::E))


the boolean bCanTick is set to true when the player begin overlap and false when it ends.