How to Toggle Selected Objects Visibility with H shortcut as in Maya I want to be able to toggle the visibility of selected objects with a shortcut (H) the way you can do in Maya and XSI, shown in the GIF. I'm guessing scrippting is needed. I've tried to do it my self but I'm new to Python and Blender and as soon as the objects are hidden they seem to no longer be in a selection state/list. Eg if I manually select the hidden object/s in the Outliner and try to print the selected object to the console, none seem to be selected. Is this possible to do with the current state of Blender 2.8?
In Blender, the way selection works is a bit different. You can't really have something "selected" when it's hidden in the viewport.

You can hide an object with H, but to unhide, you generally either undo or alt-H to unhide all hidden objects. To have the same shortcut key do both an action and its opposite is pretty uncommon in Blender. The only thing I can think of is selecting all (A for select all AA to deselect all, but they are moving away from that by making alt-A deselect all).

https://www.youtube.com/watch?v=8SXSIQpYnl8