Yes you can.
The on_xx commands set the function (as an event) to the xx key.
So once the on_xx has been processed, no matter where the code is NOW,
if the xx key is pressed, the event(your function) is triggered at the
next frame, or the end of this frame, Im not sure of that.
To disable the event, just execute an on_xx=NULL; and the event is released,
and the xx key no longer triggers any functions.