OK, first of all, jumping on another function is just making the script bigger and harder to get it right. Secondly, you had some tiny mistakes, solved them, you can try this, it's working fine.
{$CLEO}
0000:
:START
wait 0
if
key_down 121
then
0B12: 0@ = 0@ XOR 1
...