How to Get Pressed Keys from Enhanced Input Actions - UE5.1 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
first of all thank you to everybody that has watched the enhanced input video I don't know what it was but it went completely nuts so I have some feedback from this video regarding enhanced input and one question in particular that stood out was how to get which key you've pressed okay so we have our basic movement here and as you can see there is no pin for the key being pressed like this one up here if you're using enhanced input and you want the key output there's a few extra steps you have to take but it is possible so create a new function I'm calling it get action pressed keys start with adding an input call it action and set the type to input action that'll be here and you can right click and sorry query Keys mapped to action that's what it's called then plug in action to the action and the target will be the subsystem for uh for enhanced input which means we have to get controller and then cast to player controller make that a pure cast and then from here we can get the enhanced input local player subsystem throw that in there okay so let's say we have movement action here just as an example so we would plug this in here so we have the movement action going into our function and we're Gathering all the keys that are bound to movement but as I just said that gets all of them so we'll have to filter the ones being pressed so for each Loop and then from there we check each one okay that's it is input key down so we'll just go branch now the next step depends on how you want this function to operate for me I want it to return the entire array of all the Pressed Keys If there happens to be two or more if you know for sure that there will only be one key pressed at a time you could after true just return at a return node and you could just plug in from the for each Loop so on the one that is being pressed you can just return that but since I wanted to return all of them I will add a local variable down here so that's where it would be I already have it pressed keys and add unique so we'll first start by adding each of the Pressed keys from this action to an array throw that in there so if it's pressed it gets added to our list of pressed keys and that's it once that's done uncompleted we return pressed keys and I'll rename not just the keys gotta plug this into player controller of course and just to make sure this is working I'll get the display name of the key and then print string okay so let's actually plug this in now so on triggered so since we have the print string already in there it should work just like that WDAS wsad so yeah that's it and then you can do whatever you want with that you'll have all the keys here so you could see if the key being pressed is from a controller or a keyboard or if it's a mouse button uh hook it up to a for each Loop or you know whatever whatever you're looking to do with it anyway that's pretty much it thanks for watching this one I hope it helped let me know what else you would like to see and I'll see you in the next one
Info
Channel: Peanut Games
Views: 8,757
Rating: undefined out of 5
Keywords: ue, ue4, ue5, unreal engine 4, unreal engine 5, game development, tutorial, ue5.1, enhanced input, get keys, get pressed keys, how to, action event, get bindings from enhanced input, axis mappings, action mappings, deprecated, input, trigger, movement, key binding, axis, action, mapping, unreal engine, unreal engine tutorial, axis event, pressed buttons, buttons
Id: 8VuE-kCyUAU
Channel Id: undefined
Length: 6min 9sec (369 seconds)
Published: Sun Feb 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.