mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
pikvm/pikvm#306: replace quotes for hid print
This commit is contained in:
parent
c1fcfdb6ce
commit
c0afe3ba40
@ -29,7 +29,7 @@ from .mappings import WebModifiers
|
||||
|
||||
|
||||
# =====
|
||||
def text_to_web_keys(
|
||||
def text_to_web_keys( # pylint: disable=too-many-branches
|
||||
text: str,
|
||||
symmap: Dict[int, Dict[int, str]],
|
||||
shift_key: str=WebModifiers.SHIFT_LEFT,
|
||||
@ -39,16 +39,23 @@ def text_to_web_keys(
|
||||
|
||||
shifted = False
|
||||
for ch in text:
|
||||
try:
|
||||
code = ord(ch)
|
||||
if 0x20 <= code <= 0x7E:
|
||||
# https://stackoverflow.com/questions/12343987/convert-ascii-character-to-x11-keycode
|
||||
# https://www.ascii-code.com
|
||||
keys = symmap[code]
|
||||
elif code == 0x0A: # Enter:
|
||||
if ch == "\n":
|
||||
keys = {0: "Enter"}
|
||||
elif ch == "\t":
|
||||
keys = {0: "Tab"}
|
||||
elif ch == " ":
|
||||
keys = {0: "Space"}
|
||||
else:
|
||||
if ch in ["‚", "‘", "’"]:
|
||||
ch = "'"
|
||||
elif ch in ["„", "“", "”"]:
|
||||
ch = "\""
|
||||
if not ch.isprintable():
|
||||
continue
|
||||
try:
|
||||
keys = symmap[ord(ch)]
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user