Method specific to Compiz / Ubuntu-3D:
If you are using Ubuntu-3D, then you can use bind keyboard keys to terminal commands using CompizConfig Settings Manager.
- Warning: CCSM is in universe and not shipped by default for a reason, it can be flaky, so be careful in there, it can break things, if you find yourself with a broken window manager, see this question to reset your configuration.
- Install the CompizConfig Settings Manager
(CCSM) by clicking on the link.
Click on "Commands".
The terminal commands to switch between "tree" and "places" are as follows:
gsettings set org.gnome.nautilus.window-state side-pane-view "tree"
gsettings set org.gnome.nautilus.window-state side-pane-view "places"
Copy them to appropriate columns and assign keys to these commands to your wish. Here, I have chosen Ctrl + 5 and Ctrl + 6. Once you have done it properly, you can input your chosen keyboard shortcuts and see Nautilus change its view at your fingertips.
Alternate method (Not limiting to Compiz / Unity - 3D):
Search for "Keyboard" settings. Open "Shortcuts" tab. Move to "Custom Shortcuts" and click the + button. Give the shortcut appropriate name and assign keyboard shortcuts as you wish.
You should use the following commands for switching between "tree" and "places":
gsettings set org.gnome.nautilus.window-state side-pane-view "tree"
gsettings set org.gnome.nautilus.window-state side-pane-view "places"