[Expression/Text] Get last pressed key

That simple expression could give us ability to make rebindable controls.

Example:

  1. Save to variable last pressed button using said expression.
  2. Handle input using “A key is pressed (text expression)” using that variable as a parameter.

My main concern with this expression in its most simplest form is that is does not work when multiple keys are pressed.

It seems that SFML doesn’t support a list of all pressed keys (to select one quickly)… maybe you could map the keyboard as you did, but inverted to get the string from any pressed key, it would return the string of the first key pressed, in the order you mapped the keyboard :confused:

Anyway, what I want to say is that, if you can select one key (any one), there is no problem. I mean, if the game needs that you press a not-particular key to do something (for example change controls), it’s your problem if you press many keys at once, really :slight_smile:

Using SFML is not a problem in any case, I’ll find a solution. :slight_smile:

Yeah you’re right. As the potential “LastPressedKey” expression is returning only the last key, it is adapted to change controls by asking the user to press a key and store it in a variable.
During the game however, “A key is pressed (text expression)” condition must be used as usual, and it will handle properly of course multiple keys press. :slight_smile:

So I’m going to add this LastPressedKey expression I think :slight_smile:

Added the LastPressedKey string expression for next version :slight_smile:

Great. As soon as it’s released, I’ll make example game for rebindable controls.

Works great in compiled game :smiley: !
(Is it normal that doesn’t work in preview mode, as the Keyboard Input?)