MCPcopy Create free account
hub / github.com/tiny-pilot/tinypilot / _map_keycode

Function _map_keycode

app/js_to_hid.py:192–206  ·  view source on GitHub ↗
(keystroke)

Source from the content-addressed store, hash-verified

190
191
192def _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
209def _count_modifiers(keystroke):

Callers 1

convertFunction · 0.85

Calls 2

_count_modifiersFunction · 0.85

Tested by

no test coverage detected