Unfortunately it’s not really avoidable - the IDE sends a key down message to sclang so your function gets hit, but it’s one way communication. You can’t do the thing that you can ordinarily do with e.g. keyboard events where you can mark them as accepted or not to stop propagation.
would it not be a good idea to add one or two predefined shortcuts to trigger custom code ? One for loading files, and another to play a Pdef ?? I was always thinking creating some kind of Pdef.main.