Fix handling of Shift-Tab aka. Backtab

This commit is contained in:
Florian Bruhin 2018-02-28 20:46:52 +01:00
parent 65a05f334e
commit 934d586286
2 changed files with 9 additions and 3 deletions

View File

@ -105,7 +105,6 @@ def _key_to_string(key):
'unknown': 'Unknown',
# For some keys, we just want a different name
'Backtab': 'Tab',
'Escape': 'Escape',
}
# We now build our real special_names dict from the string mapping above.
@ -384,16 +383,23 @@ class KeySequence:
In addition, Shift also *is* relevant when other modifiers are
involved.
Shift-Ctrl-X should not be equivalent to Ctrl-X.
We also change Qt.Key_Backtab to Key_Tab here because nobody would
configure "Shift-Backtab" in their config.
"""
key = ev.key()
modifiers = ev.modifiers()
if modifiers & Qt.ShiftModifier and key == Qt.Key_Backtab:
key = Qt.Key_Tab
if (modifiers == Qt.ShiftModifier and
is_printable(ev.key()) and
not ev.text().isupper()):
modifiers = Qt.KeyboardModifiers()
keys = list(self._iter_keys())
keys.append(ev.key() | int(modifiers))
keys.append(key | int(modifiers))
return self.__class__(*keys)

View File

@ -51,7 +51,7 @@ KEYS = [
### misc keys
Key('Escape'), # qutebrowser has a different name from Qt
Key('Tab'),
Key('Backtab', 'Tab'), # qutebrowser has a different name from Qt
Key('Backtab'),
Key('Backspace'),
Key('Return'),
Key('Enter'),