Enable [key] only in locked patchers?

EMV's icon

This is probably very simple, but I can't seem to find the answer even after searching the forum.

How can I disable the [key] object when a patcher is in edit mode?

I am mapping the m key to an action and I don't want this action to happen every time I add a message box when tweaking the patch.

I could remap to shift-m, or an unused character, but I want to use single keys that related to the action.

Brian Gruber's icon

here's some javascript that allows bangs to be passed through only when the patcher is locked:

function bang() {
    if (this.patcher.locked) {
        outlet(0, "bang");
    }
}
EMV's icon

Thanks pizza olives and Brian Gruber for the suggestions!

I develop my patches on a Mac, but they need to run on windows too so I'll go with the javascript solution.

I imagine an external would be the nicest solution because it would be more efficient and faster, but then again this action doesn't happen so often and doesn't deal with lots of data.