Skip to main content
Inspiring
June 29, 2019
Question

Is there a way to setup a shortcut to toggle a specific layers visibility?

  • June 29, 2019
  • 3 replies
  • 2462 views

I have this reference layer that i'm turning on and off quite frequently, is there a way to setup shortcut to speed up my workflow?   Ideally would be awesome to setup keystroke "1"

    This topic has been closed for replies.

    3 replies

    rcraighead
    Legend
    June 29, 2019

    This script will toggle a layer named "Reference" on or off. It can be saved as a "JSX".

    var aDoc = app.activeDocument;

    var myLayer = aDoc.layers.getByName("Reference");

    myLayer.visible  ^= 1;

    It can be added to the "/Applications/Adobe Illustrator CC 2015.3/Presets.localized/en_US/Scripts" folder and run from within AI (after restart). CC 2015 does NOT let the user assign a keyboard shortcut to scripts. Maybe later versions do).

    For REAL automation power I'd suggest looking at Keyboard Maestro (Mac only). It allows the user to write macros in a "drag-n-drop" interface. Among many other features you can assign shortcuts to any menu item in any application. You can also run Javascript files written for any application including Adobe CC apps.

    Ton Frederiks
    Community Expert
    Community Expert
    June 30, 2019

    rcraighead  wrote

    CC 2015 does NOT let the user assign a keyboard shortcut to scripts. Maybe later versions do).

    Later versions allow to set a shortcut for an Action that uses a script.

    barbara_a7746676
    Community Expert
    Community Expert
    June 29, 2019

    Another possibility would be to create an Action. Open the Actions panel and when you create an action you can choose a function key for the action. You'll find commands to show and hide layers in the Actions panel menu.

    Inspiring
    June 29, 2019

    Thanks for the reply, the action menu is something i didn't know but i actually found an alternative way of doing this that does save a lot of time. 

    I created my reference layer into a template layer, which allowed me to use the hide template command under view, which worked perfectly.  Though maybe you can help out with another problem i ran into. 

    For some reason I can't assign shortcuts to the numbers?  What are those for? 

    macpawel
    Participating Frequently
    June 29, 2019

    If you are making an Action - you can use only F keys with CTRL or Shift - it's typical sitiuation

    barbara_a7746676
    Community Expert
    Community Expert
    June 29, 2019

    Well, since it doesn't take long to Alt/Option click the eye next to a layer to view only that layer and then Alt/Option click in the eye column again to view all layers, this may not save you much time. You would need two shortcuts, one to view only the reference layer and one to view all the layers except the reference layer. To set up the shortcut, view the file as you want to view it. Then choose View > New View and give the view a name. The view will remember what is showing and also the zoom level. Then you can go to Edit > Keyboard Shortcuts. Choose Menu Commands, and then expand the View menu to enter a keyboard shortcut. .