I was also trying to achieve this. From above codes, what I understood was that you can call getch() function multiple times in order to get both bytes getting from the function. So the ord() function is not necessary if you are just looking to use with byte objects.
while True :
if m.kbhit() :
k = m.getch()
if b'\r' == k :
break
elif k == b'\x08'or k == b'\x1b':
# b'\x08' => BACKSPACE
# b'\x1b' => ESC
pass
elif k == b'\xe0' or k == b'\x00':
k = m.getch()
if k in [b'H',b'M',b'K',b'P',b'S',b'\x08']:
# b'H' => UP ARROW
# b'M' => RIGHT ARROW
# b'K' => LEFT ARROW
# b'P' => DOWN ARROW
# b'S' => DELETE
pass
else:
print(k.decode(),end='')
else:
print(k.decode(),end='')
This code will work print any key until enter key is pressed in CMD or IDE (I was using VS CODE) You can customize inside the if for specific keys if needed