Skip to main content
Known Participant
June 30, 2025
Answered

Creating zoom shortcut

  • June 30, 2025
  • 2 replies
  • 408 views

How can I create a action or a key which can zoom out the document to a specific percentage (say 20%) whenever I press them?

Correct answer Kurt Gold

In case you want to set an absolute zoom level, you can use this javascript snippet to always go to 20 %:

 

// Absolute Zoom level: 20 %
if (app.activeDocument) {
    app.activeDocument.views[0].zoom = 0.2;
}

 

You can incorporate it into an action and assign a keyboard shortcut to the action.

2 replies

Kurt Gold
Community Expert
Kurt GoldCommunity ExpertCorrect answer
Community Expert
June 30, 2025

In case you want to set an absolute zoom level, you can use this javascript snippet to always go to 20 %:

 

// Absolute Zoom level: 20 %
if (app.activeDocument) {
    app.activeDocument.views[0].zoom = 0.2;
}

 

You can incorporate it into an action and assign a keyboard shortcut to the action.

Ton Frederiks
Community Expert
Community Expert
June 30, 2025

That works as how I understood the question.

Nicky G.
Known Participant
June 30, 2025

// Riduci lo zoom corrente del 20%

if (app.documents.length > 0) {
var doc = app.activeDocument;
var currentZoom = doc.views[0].zoom; // valore in scala (es. 1.0 = 100%)

var newZoom = currentZoom * 0.8; // riduci del 20%
doc.views[0].zoom = newZoom;

//alert("Zoom ridotto del 20%");
} else {
alert("Nessun documento aperto.");
}

Ton Frederiks
Community Expert
Community Expert
June 30, 2025

That zooms from 100 to 80% on my machine.

Nicky G.
Known Participant
June 30, 2025

And wasn't that the request? If you run the script 2 times it goes to 64% ....