Disabling The Control or Arrow Keys

Hi, I’m at the tail end of a long script and have one more piece of the puzzle to figure out - but I’m stuck. It’s probably over my skill level. Was hoping to get some help.

At the end of my script, I switch desktops using control + arrow (key code 124/control down). Then, at the very end, there’s a short window of time - less that a second - when I return to the original desktop. During this brief window, I’d like to prevent the user from manually pressing the control or R arrow keys to revert back to a previous desktop.

A simplified version of the end of my script:


repeat 2 times
	tell application "System Events" to key code 123 using {control down}
	delay 0.1
end repeat

Is there a way to temporarily disable either the control or R arrow key? I tried everything I could find on this forum but so far, no luck. I’m frazzled. I have a feeling, it may be more complicated than I think.

Thank you for any input.