Hi all, how I can get which key was pressed using blueprint?
I known that you can use override function in widgets OnKeyDown and compare if it equal to specific key, but how I can get exactly which input key was pressed and displayed in Print string ?
I am not sure what you are asking but here is an answer hope it helps:
Inside of the player blueprint, and make a new blueprint (An input key), make it the key you want to be the key that the string notices. And attach the input blueprint to a print string and type in a message with whatever you want in it.
I was asking to get key i pressed to text. If i pressed space bar i need to get it in text (key name), i need know which key has been pressed by player.
Well, if thatâs the case than I think you can still set up inputs for every key and then have them have different text strings for example:
You could set up the inputs for all your keys, and then set up print lines or print text to the input and make the text say something like (Key name) was pressed. It would take a while but it is the way that is the simplest. You could always attach an event or cast to a widget but that is a lot more time consuming and harder.
Hope that helps.
I was in the process of doing an input buffer system in BP since I didnât really see too much on it and ran across this post and used THIS post for a starting point actually.
In the future, please only use code that is relevant to the question. It can really confuse beginners who think they might need all of this to preform the very simple task.
please note that this method will not work after localization. I hit a wall with this solution, just a mere week prior to production release.
Japanese and Chinese localized builds have different âKey display namesâ than the rest of the world. German and Russian are like english, where
Space = Space
Backspace = Backspace
etc.
but for example getting the Spacebar value in Japanese version of âget display nameâ will result in ăšăăźăšăăź.
This method is therefore unusable for anything using a direct keyboard input. The proposed blueprint solution completely broke my hacking pc mini-game As of the moment I am searching for a better solution, probably going to look in the direction of reading the key values directly.
edit: found the solution. It is to compare the key structure directly and not the string value (which was stupid of me, I assumed the keycode display names are same everywhereâŚ)