Is there a way to detect ANY gamepad/keyboard input?

I’m currently using mouse location to rotate the character for keyboard movement and the right thumb stick for game pad movement. Unfortunately one of these methods overwrites the other, and I’d like to swap between the two by setting a game pad mode and keyboard mode. I want to do this by changing modes when input from the opposite device it detected.

1 Like

I would also like to know how to do this.

1 Like

Hi HelloIAmMeat and DanielKarp,

This feature was added in 4.9’s release. When you go to set up inputs in the Input section of the Project Settings, you should be able to select Any Key as you would any other key. This will react to any pressed / released event.

Hope this helps!

1 Like

i see that it has a keyboard icon next to it, is it only for any keyboard press?

I decided to give that a try to see if it would work for gamepad input as well but it seems that the entire feature is not working as intended at the moment. I do believe that it is meant to include gamepad input but I will not be sure until the feature itself is fixed. I’ve placed a bug report in for the issue itself and for your reference, the number is UE-22161.

CL 2730305 fixes the issue of AnyKey event used in an action mapping.

I can confirm that the Any Key keybinding works for Gamepad events and Keyboard events alike. The overall issue has been fixed on an internal build and will be included in a future release.

Have a nice day!

oh that’s really nice, can’t wait to get it. I need it so I can detect whenever you are using KB/M or gamepad, to separate them for menus and such.

Has this been fixed in the latest version (4.10)? I’m essentially detecting if AnyKey is pressed, then checking if the key is a GamePad key, then hiding the mouse, otherwise I’m showing the mouse, but it’s not working.

Hello Didstopia,

How are you setting it up? I went for a simple setup and just replaced the Jump binding for the Third Person template with Any Key (previously Space) and it seems to work for all keyboard inputs and gamepad inputs (aside from the Home button on an Xbox Controller.)

Why mouse X/Y doesn’t trigger Any Key event? Is it intentional?

Based on 4.10.

Hello Daverkex,

Mouse X/Y do not trigger the Any Key event due to them not being key presses such as normal keys that have a IE_Pressed and IE_Released state. The same goes for analog sticks on a gamepad.

No no, the analog sticks yes trigger the Any Key event.
If you print the key the name is “Gamepad Left|Right Thumbstick Up|Down|Left|Right”.

This is because the analog sticks can be used in two different modes, as analog sticks or as virtual directional pads. The events that you’re triggering that print these messages are the virtual direction pad bindings which are picked up once the stick goes beyond the dead zone. The analog X/-X and Y/-Y won’t be picked up by the Any Key event.

Is there a reason this is setup for all input rather than per input type (eg. an “Any Key” only for Gamepad input and an “Any Key” only for Keyboard input)? It is under the keyboard section too, making it misleading seeing as it works for all input instead of just keyboard input.

Is there a way of querying the input device via C++/Blueprints (preferably C++) on receiving Any Key input? Currently I am having to manually track every bind-able input for keyboard in an input bind, and every bind-able input for gamepad in a separate input bind, to get this functionality. I feel like this is something that should already exist if it doesn’t already (was very tedious and time-consuming to manually click through the dropdowns for all available input).

+1 to this. It would make my life easier…

EDIT: I found something which might just work.
The “ChaneInputType” InputAction has “AnyKey” Bound to it

137417-inputtype.png

I’m in 4.21.1 and I’m observing that the AnyKey event is not firing for the mouse button input keys. Intentional? Can anyone else verify this?

Desert eagle, yes, it is. Most people will just add the extra mouse button clicks.

This answer worked well for me:

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/96407-detect-if-any-key-on-gamepad-or-keyboard-is-pressed-switching-widget?p=837485#post837485

The test can be used, and the input events of the keyboard and mouse will be called, thank you