From 078f1e52d046de9eb27fb2354ef2fd1dbdaaeea7 Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Wed, 5 Jul 2017 21:45:18 +0200 Subject: [PATCH] Disable emacs bindings for Alt-Gr (Ctrl+Alt) key ref #5245 #5246 --- kivy/uix/behaviors/emacs.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kivy/uix/behaviors/emacs.py b/kivy/uix/behaviors/emacs.py index 4e131f294..b4d3adb90 100644 --- a/kivy/uix/behaviors/emacs.py +++ b/kivy/uix/behaviors/emacs.py @@ -90,14 +90,19 @@ class EmacsBehavior(object): def keyboard_on_key_down(self, window, keycode, text, modifiers): key, key_str = keycode - mod = modifiers[0] if modifiers else None + + # join the modifiers e.g. ['alt', 'ctrl'] + mod = '+'.join(modifiers) if modifiers else None is_emacs_shortcut = False if key in range(256) and self.key_bindings == 'emacs': - is_emacs_shortcut = ((mod == 'ctrl' and - chr(key) in self.bindings['ctrl'].keys()) or - (mod == 'alt' and - chr(key) in self.bindings['alt'].keys())) + if mod == 'ctrl' and chr(key) in self.bindings['ctrl'].keys(): + is_emacs_shortcut = True + elif mod == 'alt' and chr(key) in self.bindings['alt'].keys(): + is_emacs_shortcut = True + else: # e.g. ctrl+alt or alt+ctrl (alt-gr key) + is_emacs_shortcut = False + if is_emacs_shortcut: # Look up mod and key emacs_shortcut = self.bindings[mod][chr(key)]