# Enhanced Input - Detect Gamepad vs Keyboard Input

**URL:** <https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 17, 2023, 12:41pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533 "2023-07-17T12:41:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattworkman](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattworkman/32/637014_2.png) [@mattworkman](https://forums.unrealengine.com/u/mattworkman)\
**Post date:** [July 17, 2023, 12:41pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/1 "2023-07-17T12:41:48Z")

</div>

Hey,

**How do you detect if the player has pressed a Gamepad key or a Keyboard key at run time?**

With the old input system, you can get the key directly from the input event and check “Is Gamepad.”

With CommonUI, there is a specific node for this. But with Enhanced Input, I haven’t found an effective method for detecting keyboard/gamepad input at run time.

Cheers!

Matt

---

<div class="post-metadata">

**Author:** ![Bugzi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bugzi](https://forums.unrealengine.com/u/Bugzi)\
**Post date:** [July 31, 2023, 3:24pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/2 "2023-07-31T15:24:53Z")

</div>

Any chance you found out how?

I’m also looking how I can do this.

---

<div class="post-metadata">

**Author:** ![mattworkman](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattworkman/32/637014_2.png) [@mattworkman](https://forums.unrealengine.com/u/mattworkman)\
**Post date:** [August 1, 2023, 12:11pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/3 "2023-08-01T12:11:34Z")

</div>

I haven’t found a way with only Enhanced Input, I may use the old soon to be deprecated “Any Key” traditional event until I switch to Common UI.

---

<div class="post-metadata">

**Author:** ![Apothecary](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Apothecary](https://forums.unrealengine.com/u/Apothecary)\
**Post date:** [October 2, 2023, 8:33am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/4 "2023-10-02T08:33:36Z")

</div>

To my knowledge Enhanced Input has no method of checking input types but as I have done this today, I will post my solution for anyone else searching for a way to access the currently used input method during runtime.

1. In the Editor Window go to Edit \> Plugins
2. Search for **Common UI** and enable it, then restart the editor
3. The **ECommonInputType** is accessed through **Common Input Subsystem** via the **Player Controller** , therefore in Blueprints:

- Right click and search for **Get Player Controller**
- Drag from the **Return Value** pin of **Get Player Controller** and search for **Get CommonInputSubsystem**
- Drag from the **CommonInput** Node and search for **Get Current Input Type**
- From the **Return Value** pin of **Get Current Input Type** search for **Switch** for a node **Switch on ECommonInputType**

You will now have the last used input.

In C++

```auto
#include "CommonInputSubsystem.h"

```

My Enhanced Input **Look()** function incorporates the solution as

```auto
/*
			if (const APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0))
			{
				if (const ULocalPlayer* LocalPlayer = PC->GetLocalPlayer())
				{
					if (const UCommonInputSubsystem* CommonInputSubsystem = LocalPlayer->GetSubsystem<UCommonInputSubsystem>())
					{
						if (const ECommonInputType InputType = CommonInputSubsystem->GetCurrentInputType(); InputType == ECommonInputType::Gamepad)
						{
							AddControllerPitchInput(-LookValue.Y);
						}
						else
						{
							AddControllerPitchInput(LookValue.Y);
						}
						
						return;
					}
				}
			}

                        // This is here to add input regardless, should the subsystem checks fail
			AddControllerPitchInput(LookValue.Y);

```

---

<div class="post-metadata">

**Author:** ![AeroIA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AeroIA](https://forums.unrealengine.com/u/AeroIA)\
**Post date:** [December 8, 2023, 9:46pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/5 "2023-12-08T21:46:40Z")

</div>

Hi, this worked for me in the Player Controller:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/3/2e3d0bb66d39e01a4e6da451b85849c8243c46b2.png)

---

<div class="post-metadata">

**Author:** ![Evigmae](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/evigmae/32/1187349_2.png) [@Evigmae](https://forums.unrealengine.com/u/Evigmae)\
**Post date:** [December 31, 2023, 10:59am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/6 "2023-12-31T10:59:19Z")

</div>

Think nothing is stopping you from adding this old simple check where needed though.  
Just make sure to not consume the input.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/7/72791d7c4198ac37b2182cfce80ba2aada92adce.png)

---

<div class="post-metadata">

**Author:** ![BerSeeker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BerSeeker](https://forums.unrealengine.com/u/BerSeeker)\
**Post date:** [January 14, 2024, 6:34pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/7 "2024-01-14T18:34:03Z")

</div>

Or simply Creating a small function in a function library to replace the deprecated IsgamepadKey function.

 ![Capture](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/0/05048259e9edb4cda57ee2e10bdbfa56d4d0ffd7.png)

---

<div class="post-metadata">

**Author:** ![snake828](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@snake828](https://forums.unrealengine.com/u/snake828)\
**Post date:** [January 15, 2024, 3:41pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/8 "2024-01-15T15:41:01Z")

</div>

@BerSeeker 's post, hallelujah, this worked like a charm 🙂 thank you!

---

<div class="post-metadata">

**Author:** ![VioletSaint](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/violetsaint/32/88710_2.png) [@VioletSaint](https://forums.unrealengine.com/u/VioletSaint)\
**Post date:** [January 25, 2024, 8:21pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/9 "2024-01-25T20:21:13Z")

</div>

Thank you kind sir, you saved me just before a build.  
May your UE crash at least 33% less.

---

<div class="post-metadata">

**Author:** ![AlepaxHapre](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlepaxHapre](https://forums.unrealengine.com/u/AlepaxHapre)\
**Post date:** [February 3, 2024, 12:38pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/10 "2024-02-03T12:38:31Z")

</div>

That’s useful ,thx!

---

<div class="post-metadata">

**Author:** ![SgtFlexxx](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sgtflexxx/32/1194634_2.png) [@SgtFlexxx](https://forums.unrealengine.com/u/SgtFlexxx)\
**Post date:** [February 16, 2024, 9:24pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/11 "2024-02-16T21:24:50Z")

</div>

A C++ version of AerolA/Berseeker’s solution.

```auto
UInputDeviceSubsystem* InputDeviceSubsystem = GetGameInstance()->GetEngine()->GetEngineSubsystem<UInputDeviceSubsystem>();

//GetPlatformUserID() is part of the Pawn class
if (InputDeviceSubsystem->GetMostRecentlyUsedHardwareDevice(GetPlatformUserId()).PrimaryDeviceType == EHardwareDevicePrimaryType::Gamepad) {
// Code...
}

```

---

<div class="post-metadata">

**Author:** ![Alfreddiculous](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alfreddiculous](https://forums.unrealengine.com/u/Alfreddiculous)\
**Post date:** [February 22, 2024, 6:11am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/12 "2024-02-22T06:11:59Z")

</div>

Using the Input Device Subsystem did not detect the change in user input mode at runtime for me. I always output “Keyboard and Mouse” for whatever reason. I had to use the method @Apothecary outlined with the `CommonUI` plugin to provide the `CommonInputSystem`. Then I was able to see the value.

My use case is for popup control glyphs. If there’s a better or more standardized way to display dynamic glyphs (keyboard key vs gamepad button), I’d love to know it. Right now I’m binding the Widget Component image sprite to the appropriate image based on the last input type.

---

<div class="post-metadata">

**Author:** ![Manostion](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/manostion/32/901327_2.png) [@Manostion](https://forums.unrealengine.com/u/Manostion)\
**Post date:** [March 3, 2024, 8:35pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/13 "2024-03-03T20:35:49Z")

</div>

This is only vaguely related, but is there a way to also detect which keys are bound to an action in the Input Mapping Context?

For example, if I want to display a simple “Press `[E]` to open” hint but want to not only take into consideration whether a keyboard (`[E]`) or gamepad (`[X]`) is being used but also show the correct button if the player changed their keybinds?

Basically, what I want to check is what keys are mapped to `IA_Interact` and then decide what glyph to display on screen based on whether it says “Gamepad Face Button Left” (=`[X]`), “Gamepad Face Button Bottom” =(`[A]`) and so on…

---

<div class="post-metadata">

**Author:** ![Manostion](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/manostion/32/901327_2.png) [@Manostion](https://forums.unrealengine.com/u/Manostion)\
**Post date:** [March 4, 2024, 8:39am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/14 "2024-03-04T08:39:18Z")

</div>

**Update:**  
I found a way to do the above, but it feels quite messy…

1. I use the `Query Keys Mapped to Action` node for my `IA_Interact`.
2. Then I loop through the return array and get the Display Name for each mapped key.
3. Next, I use `Find Substring` on each, looking for the substring “Gamepad Face” and checking if the `Return Value` is greater than `-1`.
4. If it is (greater than `-1`), I then `Get Substring` on it, starting at position 20 (to eliminate "Gamepad Face Button "), with a Length of 10 (just to catch everything), and set the result as my `GamepadInteractKey` variable.
5. I also check for Key Display Names that return less than `0` for both the substrings `Gamepad` and `Mouse` to determine which keyboard key is mapped to `IA_Interact`, so that I can throw out that prompt correctly and dynamically, too.

It took me way too long to figure out that you need to do all this after a short delay (default of `0.2` works fine), or it won’t work on Begin Play.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/c/20cface3a501ae4b6508de55761a4481cb78092f.png)

Once that’s all done, I “just” needed to assign each face button glyph to its respective mapping… and since I offer multiple glyph sets (Xbox One/Series, Xbox 360, PS4, PS5, Switch Pro and “generic”, I had to do that for each possible set x4… messy af. 😅

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/2/c020e6df3d99e53e7e611e6574d6a797680dfe3d.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/b/15bd406685f0feab276bf4b0115fc79fe8560aff.jpeg)

It does work very well, though.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/e/10eacce016ee21eea2a18aa4afa4c4e460262df6.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/d/3ed4809ccd1bc963d9982659b325ea2baa30826e.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/1/381e0f8f95bdabd6408a44f519bfe999bf15bfb1.jpeg)

---

<div class="post-metadata">

**Author:** ![OverRated\_AU](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/overrated_au/32/1008648_2.png) [@OverRated\_AU](https://forums.unrealengine.com/u/OverRated_AU)\
**Post date:** [May 30, 2024, 2:19am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/15 "2024-05-30T02:19:10Z")

</div>

If your using C++ just make a child class of UEnhancedPlayerInput and add a bool to your player controller and just set it like below.

```auto

bool URPEnhancedPlayerInput::InputKey(const FInputKeyParams& Params)
{
	if (PlayerController)
	{
		PlayerController->IsGamepadBeingUsed = Params.IsGamepad();
        }
	return Super::InputKey(Params);
}

```

---

<div class="post-metadata">

**Author:** ![indianapapi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@indianapapi](https://forums.unrealengine.com/u/indianapapi)\
**Post date:** [January 25, 2025, 8:16pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/16 "2025-01-25T20:16:40Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![Razivoid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Razivoid](https://forums.unrealengine.com/u/Razivoid)\
**Post date:** [February 27, 2025, 12:41pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/17 "2025-02-27T12:41:08Z")

</div>

> [@mattworkman](#):
>
> How do you detect if the player has pressed a Gamepad key or a Keyboard key at run time?

Quite simply, by using multiple `InputAction`’s. For example you can create two actions:  
`IA_Jump`  
`IA_JumpController`

Inside your `InputContextMapping` you can assign different keys here. The action events are exposed to Blueprints so I don’t see why you couldn’t implement whatever you’re trying to do. It’s difficult to suggest the most elegant approach when you haven’t given any context in what you’re trying to do.

There is also opportunity to create multiple `IMC`’s and assign when there’s a hardware change, there’s an `OnInputDeviceConnectionChange` delegate to detect this. You will want to make sure you check which controller for any logic on this.

In 5.3 we now have `UEnhancedInputUserSettings` which supersedes the depreciated _`PlayerMappableInputConfig`_. You can extend this class to put any logic inside, and assign in project settings.

I would take some time in playing with the above classes as there are better methods than the expensive checks on tick/input change examples given above.

---

<div class="post-metadata">

**Author:** ![elguapador](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@elguapador](https://forums.unrealengine.com/u/elguapador)\
**Post date:** [May 28, 2025, 8:03am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/19 "2025-05-28T08:03:35Z")

</div>

An alternative to this if you don’t have (and can’t be bothered to make and configure a new input class):

```auto
// playercontroller.cpp
void AMyPlayerController::BeginPlay()
{
    Super::BeginPlay();

	UInputDeviceSubsystem* InputDeviceSubsystem = GEngine->GetEngineSubsystem<UInputDeviceSubsystem>();
	InputDeviceSubsystem->OnInputHardwareDeviceChanged.AddDynamic(this, &AGamePlayerController::OnInputHardwareChanged);
	bIsUsingController = InputDeviceSubsystem->GetMostRecentlyUsedHardwareDevice(GetLocalPlayer()->GetPlatformUserId()).PrimaryDeviceType == EHardwareDevicePrimaryType::Gamepad;
}

void AMyPlayerController::OnInputHardwareChanged(const FPlatformUserId UserId, const FInputDeviceId DeviceId)
{
	UInputDeviceSubsystem* InputDeviceSubsystem = GEngine->GetEngineSubsystem<UInputDeviceSubsystem>();
	bIsUsingController = InputDeviceSubsystem->GetMostRecentlyUsedHardwareDevice(UserId).PrimaryDeviceType == EHardwareDevicePrimaryType::Gamepad;
}

```

This only fires when input from a different hardware input is detected, rather than every time you press any key. Confirmed working on 5.3.

---

<div class="post-metadata">

**Author:** ![MonkiDG](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monkidg/32/925882_2.png) [@MonkiDG](https://forums.unrealengine.com/u/MonkiDG)\
**Post date:** [June 11, 2025, 10:37am UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/20 "2025-06-11T10:37:18Z")

</div>

How to detect if the gamepad is from Xbox or PlayStation?

---

<div class="post-metadata">

**Author:** ![Groatse](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Groatse](https://forums.unrealengine.com/u/Groatse)\
**Post date:** [September 19, 2025, 5:03pm UTC](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533/21 "2025-09-19T17:03:16Z")

</div>

Or just do this in your controller.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/d/4dd08aa850cd187065311f7a33417729e1d0051e.png)

[Next page](https://forums.unrealengine.com/t/enhanced-input-detect-gamepad-vs-keyboard-input/1231533.md?page=2)
