How to detect clicks on empty space via python?
It's actually really simple:


Go to User Preferences > Input and change the filter type from Name to Key-Binding
Search for action and find the 3D View category
Change view3d.cursor3d to object.select_all
Set Action to Deselect





Clear search filter
Expand 3D View > Mesh and Add New
Set it to mesh.select_all and Deselect
Bind it to Mouse, Action and Press