Create hotkeys for showing the Grid and Wireframe on/off

Is there a way to create a custom hotkey that will toggle the Grid on/off?
Thinking this should be easy for someone that knows Python and Blender.

Also thinking about a custom hotkey for toggling Wireframe on/off. Same as opening Overlays and checking/unchecking the checkbox, for both Grid and Wireframe.

Open User Preferences window.
Go to Keymap Tab.
Expand 3D View -> 3D View (Global) section.
Press + Add New button.
In new shortcut panel created, write wm.context_toggle as identifier of operator to call.
Then, in Context Attributes field, write space_data.overlay.show_floor
Associated shortcut will turn ON/OFF the Grid.

For wireframe, repeat same steps but just write show_wireframes instead of show_floor.
For another option of same panel, in order to know what words to use :
Go to Interface Tab in User Preferences window.
Enable Python Tooltips checkbox of Display panel.
After that, hovering the option who should an hotkey will display tooltip showing words to use.


Amazing, it works!

I’ve gotten this really twisted idea that all shortcuts used often should be reached with my left hand. The other hand I hold my Wacom pen all the time.

As a tip, a thank you, with AutoHotKey on PC and KeyboardMaestro on Mac, I have a lot of custom keys on the almost unused Windows key on PC and Ctrl key on Mac. This is also handy, if your using several different 3D apps (on different systems). So in AutoHotKey I add this:

; #=Win ^=Ctrl +=Shift !=Alt
#IfWinActive, ahk_exe blender.exe
  $#g:: ; Toggle Grid
    send !+^g
  $#w:: ; Toggle Wireframe
    send !+^w

And as a shortcut in Blender I have the custom keys as Shift, Alt, Ctrl + W and G.

PS. To use Win + G key on Windows without a game recorder showing up, go to settings and search for game bar shortcuts and turn it off.

PPS. You will also run into the problem of Blender already having a hotkey for Shift Alt Ctrl + G. Something to remove object from all collections? So I do understand why people don’t do this stuff often, so many hotkeys that can break. I just unclicked that, don’t think I ever will use it.