Keyboard Shortcut to Zoom in Incrementally in Preview (Like Trackpad Pinch or Similar)?

First time user here. When I work my secondary monitor has three preview windows filing my screen, displaying pdf-files of academic articles. The margins are quite large in these articles, and in order to make the text bigger I zoom in enough in each so that the whole width of the texts fills the three windows with minimal margins and largest text possible. I normally do this with my trackpad that do this gradually, but I would like to only use my external keyboard. I know the shortcut Option-Command-Plus (+), but it zooms in in way too big increments which makes it impossible to find the sweet spot (especially with small windows). Is there a way to adjust this zooming so that it zooms in "less at the time" when using keyboard shortcut? Could this be done in keyboard maestro maybe?

Note: I do not want the "accessibility zoom" as that just enlarges the entire screen like a bit map. The best thing would of course be to be able to set a default zoom as soon as I open preview... As a last solution I am willing to change pdf reader, but would rather not.

Hmm. Fair question. Well, if you ensure that View/Zoom-to-fit is checked, then the problem becomes one of changing the window size. That seems to be infinitely variable. You can assign a keyboard key to a macro that increases the window size by 1%, here's how you would do that:

This will increase the window size by 1%. You could also decrease it by using the number 99%.

I have no idea whether you will like this solution or not, but it's not a bad solution.

Upon further reflection I'm wondering if you meant you didn't want to see the whole page, just a part of it. There's a way to do that in Preview. Just use the mouse to select the region you want to see, then click on View / Zoom to Selection (Command-*). That works except it won't resize the window for you, so you end up with a little more than you selected. KM isn't required for that. It works fairly well, thanks for making me figure that out.

1 Like

Thank you so much, your last reply was exactly what I was looking for!
I made a script that drags the rectangular selection over the text to choose zoom level and press "zoom to selection". I got it to work exactly as I wanted, but the whole action takes a couple of seconds. Is that just how it is, or is it possible to speed up the click and drag action?

For reference, here is a screenshot of the actions. Note: the first and last is just to focus on window and then get the selection away.

You are probably correct that the drag process does take some time. But a couple of seconds? If I were you, what I would do is count the time accurately by starting this macro with a Set Variable to Calculation action that assigns the value of MS to a variable called TIMER. Then at the end of the macro assign the value of MS-TIMER to TIMER. That way at the end the variable TIMER would have the number of Milliseconds that the whole macro took. Using this approach you could figure out where those seconds are being lost. I think (and I could be wrong!) there is a default spacing between actions of 0.02 seconds, which you can change, but I don't think this is part of your problem here.

I took the time with external timer. It takes 3 seconds. I did a screen recording and uploaded it to youtube so you can see. Just when you see the cursor move to preview, the hotkey has ben pressed.

I tried to read and find step by step how do the set variable timer that you outlined, but it takes a while for an absolute beginner like me to learn this.
However, it seems obvious just from watching the action, that it is the click and drag that takes time... Any simple fixes, or just something to live with?

The video helps. Something looks suspicious. Have you ever used the following action, with some number in the text field, in any of your programs?...

I have to ask because that could theoretically cause the delays you are seeing. If not, I'll consider other options.

No, I have just started using Keyboard Maestro, so have only used very simple actions, literally just "keystroke", "move and click", "simulate scroll wheel", and "repeat actions".
I use the Magnet app for screen management, but can't think of anything else relevant that could interfere

Ok, I will test your macro on my Mac and see what happens.

Thanks! Note: I added an action keystroke to the beginning of the macro (after I took screenshot over) that changes from text selection to rectangular selection (under tools in preview). Text selection is default so won't work unless

I understand that last point. What I don't understand is why you have a macro that sends a keystroke called CMD-SHIFT-@ when the correct command for zoom to zoom to selection is CMD-*

I also don't know what Magnet does but that doesn't concern me at the moment.

SHIFT-@ is just how I get * on my Norwegian keyboard.

Yes I'm testing it now. One thing I advise is that you don't activate a window using the mouse to click in it. There's an action called Activate a Specific Application which is far less confusing to people who read the actions. But that's not hindering me. Just a tip.

Thanks for tip, will do that next time.
Also my internal MacBook Pro keyboard actually is English (not pictured), but I have set keyboard language to Norwegian in MacOs, and now I also use a Norwegian physical external keyboard. But it hasn't caused any problems so far with Keyboard maestro or other hotkeys.

Also: The macro and video clip is for my left external monitor (got two monitors connected, one on each side of MacBook internal display). I used Magnet to get preview to 1/3 of my left external monitor.

Whenever I do switch active apps on the screen, I tend to add a "Pause 0.1 seconds" action right after it because it seems KM acts faster than the OS and without the pause the app may miss the keystroke you send to it. SO you will see that in my code snippet below. Sometimes I add little "play sounds" actions so that I can hear the actual sounds of actions executing which helps me a bit in this case. I can literally hear that the 1.5 seconds delay is entirely caused by the Mouse Drag action in this macro. Since yours is taking 3 seconds, that appears abnormal. Why not try my code and see if you get 1.5 seconds or 3 seconds?

I haven't solved your problem yet, but I'm not finished with ideas. I think the first thing to do, if you want to figure this out, is for you to enter my macro and test it on your Mac. At the end it will tell you how long it took. For me it's about 1.5 seconds. Adding the little Tink actions may give you a little insight too. Notice that my central Move Mouse action just uses random locations, which I think is a little more robust for good testing. Also notice that I didn't include any Release Mouse action because I think that's functionless in a case like this. As far as my experience goes, the Drag releases the mouse already.

Remember I'm not one of the elite troubleshooters here so you get what you pay for. But I have helped a few people this week. :slight_smile:

1 Like

Sleepy, thank you so much for taking the time to look into this. I really appreciate it. I will try to enter this into my Keyboard Maestro now

Some people may criticize me for not uploading the macro as a file for you, but to be honest, I only know how to upload files into new threads. And besides, my post is about debugging techniques as much as it is trying to solve your problem. So to develop those techniques you need to be entering actions like this all the time in the future. We all learn from each other. And it's time I go get some breakfast.

So I tried typing in your macro the best I could. Got two fast "tinks". Preview got focused, no zoom, but I got an error message about the random move mouse location. See my screen recording.

1 I assumed that your first keystroke action was for Rectangular Selection, so I replaced that with the obscure shortcut I have assigned to Tools: Rectangual Selection.

2 You mentioned and used "activate a specific application" in this macro. How does that work when I have multiple preview windows side by side and need to focus on one to zoom. Don't I have to activate it with mouse?

Thanks again for you effort helping out a beginner