I would have to guess that it's not working because events run top to bottom, it might be setting a boolean true and then false again in the same tick. If your conditions are set up like if false then set to true, if true then set to false. You could press a key, then pass the current variable through a function to check it.