Branch Condition on Any key press

I want to create a conditional branch that triggers an event on ANY key press. The help file says, 

Input.dir8 Checks the status of the directional buttons, translates the data into a specialized 8-direction input format, and returns the number pad equivalent (1, 2, 3, 4, 6, 7, 8, 9).

If no directional buttons are being pressed (or the equivalent), returns 0."
This doesn't actually work for me when the event is triggered by "Player Touch". Here is my script

Kepress.png

The script works correctly if I change the trigger to "Action Button". Then the picture displays after the player hits space bar and erases when the player moves in any direction.
If you're using player touch, you have to actually move in order to trigger it?
What happens is that when the player touches the event it simply flickers the picture on and off as if the initial key press that activates the player touch part of the event does not get erased from the keyboard register.

What should happens is as follows:

Keyboard press to trigger event--->register stores VALUE> 0---event is triggered--->Register returns to 0

What seems to be happening is:

Keyboard press to trigger event--->register stores VALUE> 0---event is triggered--->register continues to store VALUE> 0.

So the net effect is that after a Player Touch triggers the event the register never records a value of 0 even though the character is non-moving.
You need to make an Input.update script call to clear out the value because event commands are processed in a single loop.
I thought of that. The problem is that the two different commands(Input.update vs. Player Touch) simply compete with one another and the picture only sticks about 1/2 the time, which isn't an actual improvement from my point of view.
you need a wait command after the loop


or you need to place the show picture command in a different event.


what happens is that the picture gets erased and the loop broken, but then the event is triggered again because you (as the player) are too slow to release the button before the entire event is triggered again by player touch.
Thanks for your reply Andar

edit:

Waiting does work so long as the waiting is put at the beginning of the script and outside of the loop.

Loop1.png

That's what works for me.

Original thread: https://forums.rpgmakerweb.com/threads/branch-condition-on-any-key-press.22764/