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: 11 additions & 0 deletions lib/pynput/keyboard/_darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ def _event_to_key(self, event):
if key in self._SPECIAL_KEYS:
return self._SPECIAL_KEYS[key]

flags = Quartz.CGEventGetFlags(event)

shift_down = bool(flags & Quartz.kCGEventFlagMaskShift)
ctrl_down = bool(flags & Quartz.kCGEventFlagMaskControl)
option_down = bool(flags & Quartz.kCGEventFlagMaskAlternate)
cmd_down = bool(flags & Quartz.kCGEventFlagMaskCommand)

# ...checking for non-unicode chars pressed to get raw char pressed...
if option_down and any([shift_down, ctrl_down, cmd_down]):
return KeyCode.from_char(SYMBOLS[vk], vk=vk)

# ...then try characters...
length, chars = CGEventKeyboardGetUnicodeString(event, 100, None, None)
try:
Expand Down