How to create a shortcut to dim the screen with keyboard?

my goal is to be able to make a command that can do the same thing as the option "Darken screen when inactive".
I've researched before how to try to do this but no answer really helps me to do this, I tried to create based on the lines that are here power management - How do I stop the lock screen from dimming to black? - Ask Ubuntu, but without success.