Skip to main content
brodyw91135619
Participant
February 14, 2023
Question

Hot Key for Switching Between Layer Select and Mask Select

  • February 14, 2023
  • 2 replies
  • 1200 views

So I recently discovered the hotkey for switching from layer selection to mask selection is cmd+\ Mac and (ctr+\) Win and to switch back to the layer selection is (cmd+2) Mac | (ctrl+2) Win. Is there a way to make just cmd+\ the only hotkey and have that switch back and forth from layer and mask selection in the layers panel rather than a second hotkey? I tried to find it in the keyboard shortcuts menu, but couldn't. Much appreciated. 

This topic has been closed for replies.

2 replies

PECourtejoie
Community Expert
Community Expert
February 14, 2023

Hi, I think that those shortcuts are hardcoded, and cannot be changed. To me, it sounds like it might be a job for a script like Toggletator. Check in its manual: https://toggletator-manual.readthedocs.io/en/latest/scripts/

https://kritskiy.gumroad.com/l/toggle

Stephen Marsh
Community Expert
Community Expert
February 14, 2023

There are scripts that can have a new/different keyboard shortcut set against them. I'll post the links to past topics or code later.

Stephen Marsh
Community Expert
Community Expert
February 14, 2023

A toggle option:

 

/* 
Based on a script by jazz-y
https://community.adobe.com/t5/photoshop-ecosystem-discussions/detect-if-mask-or-layer-is-selected-with-js-script/m-p/11153109
*/

s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasUserMask'));
r.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).getBoolean(p)) {
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
    (r = new ActionReference()).putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
    layerName = executeActionGet(r).getString(p);

    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('channelName'));
    r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
    channelName = executeActionGet(r).getString(p);

    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('alphaChannelOptions'));
    r.putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
    alphaChannel = executeActionGet(r).hasKey(p)

    if (channelName.indexOf(layerName) == 0 && !alphaChannel) {
        // var select = confirm('Layer mask selected\nSelect layer?') ? 'RGB' : null
        var select = 'RGB';
    } else {
        // var select = confirm('Layer selecter\nSelect mask?') ? 'mask' : null
        var select = 'mask';
    }
    if (select) {
        (r = new ActionReference()).putEnumerated(s2t("channel"), s2t("channel"), s2t(select));
        (d = new ActionDescriptor).putReference(s2t("null"), r);
        executeAction(s2t("select"), d, DialogModes.NO);
    }
}

 

 

Mask selection only:

 

selectLayerCompositeChannel("mask");

function selectLayerCompositeChannel(chanPara) {
    // v1.0, Stephen Marsh
    // "RGB" | "mask"
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( chanPara ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor.putBoolean( s2t( "makeVisible" ), false );
	executeAction(s2t( "select" ), descriptor, DialogModes.NO);
}

 

 

Layer selection only:

 

selectLayerCompositeChannel("RGB");

function selectLayerCompositeChannel(chanPara) {
	// v1.0, Stephen Marsh
    // "RGB" | "mask"
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( chanPara ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor.putBoolean( s2t( "makeVisible" ), false );
	executeAction(s2t( "select" ), descriptor, DialogModes.NO);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html