Skip to content

Commit

Permalink
Add a safety catch for unknown keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 6, 2024
1 parent 6322e3e commit 5f4127e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gtk/src/toga_gtk/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 5f4127e

Please sign in to comment.