Hiding segments with hot key

I need to “hide” all of my segmentations so that I can see only the volume underneath. I would like to map this to a keyboard shortcut so that I can toggle it on and off swiftly.
So far my attempts have not worked:

def hide_segment(segmentID):
    segmentationNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLSegmentationNode")
    displayNode = segmentationNode.GetDisplayNode()
    displayNode.SetSegmentVisibility(segmentID, False)

This hides only one segment. You say you want to hide all your segmentations so this only hides some of that.

displayNode.SetVisibility(False) hides a whole segmentation. Or segmentationNode.SetDisplayVisibility(False) the same thing.

To add a shortcut here’s a sample script from the script repository:
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#customize-keyboard-shortcuts

To show/hide you’ll need something like
segmentationNode.SetDisplayVisibility(not segmentationNode.GetDisplayVisibility())