Skip to main content
Known Participant
Jun 30, 2025 4:37 PM UTC
Answered

Creating zoom shortcut

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?

Kurt Gold
Kurt GoldCorrect answer
Community Expert
Jun 30, 2025 7:18 PM UTC

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.

6 replies

Kurt Gold
Community Expert
Kurt GoldCommunity ExpertCorrect answer
Community Expert
Jun 30, 2025 7:18 PM UTC

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.

Translate
Ton Frederiks
Community Expert
Community Expert
Jun 30, 2025 7:26 PM UTC

That works as how I understood the question.

Translate
Nicky G.
Known Participant
Jun 30, 2025 5:44 PM UTC

// 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.");
}

Translate
Ton Frederiks
Community Expert
Community Expert
Jun 30, 2025 6:49 PM UTC

That zooms from 100 to 80% on my machine.

Translate
Nicky G.
Known Participant
Jun 30, 2025 6:55 PM UTC

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

Translate