File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed
Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -20,16 +20,26 @@ def readchar() -> str:
2020 return ch
2121
2222
23- def readkey (getchar_fn = None ):
24- getchar = getchar_fn or readchar
25- c1 = getchar ()
26- if ord (c1 ) != 0x1B :
23+ def readkey () -> str :
24+ """Get a keypress. If an escaped key is pressed, the full sequence is
25+ read and returned as noted in `_posix_key.py`."""
26+
27+ c1 = readchar ()
28+
29+ if c1 != "\x1B " :
2730 return c1
28- c2 = getchar ()
29- if ord (c2 ) != 0x5B :
31+
32+ c2 = readchar ()
33+ if c2 not in "\x4F \x5B " :
3034 return c1 + c2
31- c3 = getchar ()
32- if ord (c3 ) != 0x33 :
35+
36+ c3 = readchar ()
37+ if c3 not in "\x31 \x32 \x33 \x35 \x36 " :
3338 return c1 + c2 + c3
34- c4 = getchar ()
35- return c1 + c2 + c3 + c4
39+
40+ c4 = readchar ()
41+ if c4 not in "\x30 \x31 \x33 \x34 \x35 \x37 \x38 \x39 " :
42+ return c1 + c2 + c3 + c4
43+
44+ c5 = readchar ()
45+ return c1 + c2 + c3 + c4 + c5
You can’t perform that action at this time.
0 commit comments