(keystroke)
| 190 | |
| 191 | |
| 192 | def _map_keycode(keystroke): |
| 193 | # If the current key press is a modifier key and it's the *only* modifier |
| 194 | # being pressed, treat it as a special case where we remap the HID code to |
| 195 | # KEYCODE_NONE. This is based on a report that certain KVMs only recognize |
| 196 | # a modifier keystroke if the HID code is KEYCODE_NONE, but we should verify |
| 197 | # that it matches behavior from normal USB keyboards. |
| 198 | if (keystroke.code in _MODIFIER_KEYCODES and |
| 199 | _count_modifiers(keystroke) == 1): |
| 200 | return hid.KEYCODE_NONE |
| 201 | |
| 202 | try: |
| 203 | return _MAPPING[keystroke.code] |
| 204 | except KeyError as e: |
| 205 | raise UnrecognizedKeyCodeError( |
| 206 | f'Unrecognized key code {keystroke.key} {keystroke.code}') from e |
| 207 | |
| 208 | |
| 209 | def _count_modifiers(keystroke): |
no test coverage detected