First you have to prepare two AppleScripts, one to increase the size of the Dock and one to decrease.
You may run AppleScript Editor, write and test them.
tell application "System Events"
-- get dock size (decimal in range 0 -- 1)
set docksize to dock size of dock preferences
-- increase version
set docksize to docksize + 0.05
-- decrease version (commented)
-- set docksize to docksize - 0.05
-- constrain value to 0.1 -- 1.0
if docksize > 1 then docksize = 1
if docksize < 0.1 then docksize = 0.1
-- set dock size
set dock size of dock preferences to docksize
end tell
The dock size is a value ranging from 0 to 1.
The above script increases / decreases the size by 0.05 steps.
You may choose a different formula according to your needs.
The next steps are
Create and save a new service with Automator that run an AppleScript
Assign a keyboard shortcut to the service created via System Preferences
Do it twice: for the increase and decrease shortcut.
When you create the services with Automator the AppleScripts run are the ones you prepared for increase/decrease the Dock size.
Instructions on how to create the service and assign an AppleScript to run are here:
How do I assign a keyboard shortcut to an AppleScript I wrote?
Bottom note:
Some suggested in the comments to resize the dock by issuing the following terminal commands
defaults write com.apple.dock tilesize -int 32; killall Dock
so I did in the first version of this answer.
However this approach involves restarting the Dock application with several drawbacks.
As user3439894 suggested the Dock may be resized via AppleScript using System Events
. This way the action takes place faster and more gracefully, so I updated my answer.
defaults write com.apple.dock tilesize -int 32; killall Dock
– Ruskes Nov 12 '18 at 19:25