Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/pynput/_util/xorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def _find_mask(display, symbol):
modifier_keycode = display.keysym_to_keycode(
Xlib.XK.string_to_keysym(symbol))

if modifier_keycode == 0:
# No such modifier key defined in the display
return 0

for index, keycodes in enumerate(display.get_modifier_mapping()):
for keycode in keycodes:
if keycode == modifier_keycode:
Expand Down Expand Up @@ -320,8 +324,13 @@ def keyboard_mapping(display):
if not normalized:
continue

group_states = [False, True]
if group_mask == 0:
# No altgr keysyms, so we can skip this group
group_states = [False]

# Iterate over the groups to extract the shift and modifier state
for groups, group in zip(normalized, (False, True)):
for groups, group in zip(normalized, group_states):
for keysym, shift in zip(groups, (False, True)):
if not keysym:
continue
Expand Down