diff --git a/gtk/src/toga_gtk/keys.py b/gtk/src/toga_gtk/keys.py index 0744027f23..6a05c5283e 100644 --- a/gtk/src/toga_gtk/keys.py +++ b/gtk/src/toga_gtk/keys.py @@ -189,7 +189,14 @@ def toga_key(event): """Convert a GDK Key Event into a Toga key.""" - key = GDK_KEYS[event.keyval] + try: + key = GDK_KEYS[event.keyval] + except KeyError: # pragma: no cover + # Ignore any key event code we can't map. This can happen for weird key + # combination (ctrl-alt-tux), and if the X server has weird key + # bindings. If we can't map it, we can't really type it either, so we + # need to no-cover this branch. + return None modifiers = set()