if your just looking to find a way to toggle the easiest way would be to use a flip flop. this would enable in your case the first time the input is pressed collision to be enabled, then the second time inputs pressed collision to be disabled. see the picture below method 1.
another method would be to use a variable to control the flow of the script as in the second method in the picture below. basically on key input you set the variable. its the same basic method as above but just done in a different way.