I have been using the python solution presented in this answer, which has worked well from 2.6 to 2.10 for me, and still works in the LTR 2.8.4. I can't get it to work with 2.12 (and recent point release 2.12.1).
I have my .qgis2/python/startup.py configured based on the answer linked above.
from functools import partial
from qgis.utils import iface
from PyQt4.QtCore import *
from PyQt4.QtGui import *
mappings = {"Layers": Qt.ALT + Qt.Key_1,
"Browser": Qt.ALT + Qt.Key_2}
shortcuts = []
def activated(dock):
dock = iface.mainWindow().findChild(QDockWidget, dock)
visible = dock.isVisible()
dock.setVisible(not visible)
def bind():
for dock, keys in mappings.iteritems():
short = QShortcut(QKeySequence(keys), iface.mainWindow())
short.setContext(Qt.ApplicationShortcut)
short.activated.connect(partial(activated, dock))
shortcuts.append(short)
bind()
From the python console I am able to toggle the visibility of each panel using .setVisible(True/False). However I can't seem to get the keys to bind.