That thread linked to by Harry Drew is an abomination… You will find only regret. It’s all for the old input system too, which is probably why it’s such a disaster.
After giving up on finding a good solution through web search (which lead me only here), I just guessed my way to how you should actually be doing it. It was easy to find through trial and error.
There are like a dozen different ways you can handle inputs with the new system, but all the good ones will utilize events or messages which will provide you with ‘context’. If you’re not using the callback context, you’re not using the new input system, it’s as simple as that.
context.control.displayName ← that’s what you need, that’s how you display the key that’s pressed.
Here’s example code to show you how I’m currently doing it.
The example above shows one of many ways to get the callback context from a keypress event. There are simpler ways, there are more complex ways; this is a decent one, a good way to use the new input system that I would recommend.
One of the key benefits of the new input system is that using events like these you don’t have to check every frame if a key was pressed, you just get the event sent when the key is pressed instead which can potentially save you a lot of resources that would have gone into checking for inputs with the old input system .
The bit in that code you’re looking for ultimately is print(context.control.displayName);
It prints the displayname of the key that was pressed to the console. Looks like this: