How do I get the Keyboard key linked to an action mapping?

Hi,

I want to show on the hud, the key to press to activate/deactivate game features, like ‘A’, ‘B’, ‘1’ , ‘2’, ‘3’ that would be keyboards shortcuts

I use this BP code but the display name is not what I need, I want the single keyboard key

  • is there a way to get the actual key ?
  • do I have to do it in C++ ? do you have any code that does that ?

thanks for your help

Apparently you can not retrieve the short key name in Blueprints.
In c++ this can be done:

FKey SomeKey;
SomeKey.GetDisplayName(false)
// false for short, true for long.

You’d still end up with a text for some buttons like “enter” or “PgDown” instead of “Page Down” simply because they would require an icon otherwise. Other keys like “Backslash” become “\”

2 Likes

yeah I just made a function that converts long display names
I only call it once so I dont expect any performances issues

thanks mate, good to know