diff options
author | Maxim Devaev <[email protected]> | 2022-09-23 16:06:35 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-09-23 16:06:35 +0300 |
commit | 737550e768613124046979b4ac35cf497ab627b6 (patch) | |
tree | 026adddd8c70226a971b64603987d97931b66643 /kvmd/apps | |
parent | 51447bc436a65d56ae2e1369250fdfd988e89969 (diff) |
refactoring
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/vnc/server.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index c6ea076a..9e2dd79b 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -327,21 +327,20 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes async def _on_key_event(self, code: int, state: bool) -> None: is_modifier = self.__switch_modifiers(code, state) - if self.__kvmd_ws: - web_keys = self.__symmap.get(code) - if web_keys: - if is_modifier: - web_key = web_keys.get(0) - else: - web_key = web_keys.get(self.__modifiers) - if web_key is None: - web_key = web_keys.get(0) - if web_key is not None: - await self.__kvmd_ws.send_key_event(web_key, state) + variants = self.__symmap.get(code) + if variants: + if is_modifier: + web_key = variants.get(0) + else: + web_key = variants.get(self.__modifiers) + if web_key is None: + web_key = variants.get(0) + if web_key and self.__kvmd_ws: + await self.__kvmd_ws.send_key_event(web_key, state) async def _on_ext_key_event(self, code: int, state: bool) -> None: web_key = AT1_TO_WEB.get(code) - if web_key is not None: + if web_key: self.__switch_modifiers(web_key, state) # Предполагаем, что модификаторы всегда известны if self.__kvmd_ws: await self.__kvmd_ws.send_key_event(web_key, state) |