Event not running when checking for key pressed

AnswerStackCategory: Clickteam Fusion 2.5Event not running when checking for key pressed
Aaron Roy asked 3 years ago

I have a switch that I want to toggle between states if user presses CTRL key.
I have 2 events. 
The first event checks if CTRL pressed and state is 1, then set state to 0
The next event checks if CTRL pressed and state is 0, then set state to 1
Problem: The first event never runs, only the second one.  Once the switch is turned on (=1) I cannot turn it back off.  Does anyone know why the first event is not running even though both conditions are being met?
If I change the first event to check a different key (say Q) then everything works fine.  But seems it will not run the first event if I check for the same key pressed (CTRL).
I have a sample file, but don’t know how to attach it here.

1 Answers
Danny Staff answered 3 years ago

Hey Aaron,
This happens because Fusion is parsing both events within the same ‘tick’. To avoid this, use a flag rather than an alterable value to determine the ‘on/off’ status. Flags are toggled once per tick.
So instead you would have:
– Flag Enabled: Do This
– Flag Disabled: Do That

User presses CTRL: Toggle Flag

Aaron Roy replied 3 years ago

Thank you Danny. Is there any resource I can use to understand Fusion parsing in more detail?