# Get user's input from keyboard press in C++

**URL:** <https://forums.unrealengine.com/t/get-users-input-from-keyboard-press-in-c/792363>\
**Category:** C++\
**Tags:** unreal-engine, keyboard, question, Blueprint, CPP\
**Created:** [March 16, 2023, 5:56pm UTC](https://forums.unrealengine.com/t/get-users-input-from-keyboard-press-in-c/792363 "2023-03-16T17:56:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xianthryllis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xianthryllis](https://forums.unrealengine.com/u/xianthryllis)\
**Post date:** [March 16, 2023, 5:56pm UTC](https://forums.unrealengine.com/t/get-users-input-from-keyboard-press-in-c/792363/1 "2023-03-16T17:56:39Z")

</div>

I have the following code in my DomeCameraPawn class:

```auto
void ADomeCameraPawn::MoveCameraUp() {
	FVector Location = GetActorLocation();
	FVector VectorUp = FVector(0, 0, MovementIncrement);
	Location += VectorUp;
	SetActorLocation(Location);
}

void ADomeCameraPawn::MoveCameraDown() {
	FVector Location = GetActorLocation();
	FVector VectorDown = FVector(0, 0, -MovementIncrement);
	Location += VectorDown;
	SetActorLocation(Location);
}

```

Initially in the blueprint, I’ve set these to respond to keyboard press events:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/3/0/b30a332dd6238336ddfaf4f8d572b583b425fa9d.png)

But, I want my code to be almost purely in C++.

So I was thinking of taking the user input (keyboard presses) in the code itself and then connecting them to the MoveCameraUp and MoveCameraDown functions using a simple if/else.

However, I can’t seem to find how to take in user inputs. I was told to use PlayerController  
or GetFirstPlayerController() but I’m lost at how. Here is one attempt that failed:

```auto
if (UWorld* World = GetWorld())
{
FInputKeyManager* input = World->GetFirstPlayerController()->PlayerInput();
}

```

TIA for any help or guide!
