Typically we copy only one byte. But escape sequences have a maximum
length of 8 bytes (e.g. CTRL+F8).
We have to consider the case with wrap around. This would require two
memcpy() calls.
The coding would neither get faster in the average nor less complex
using memcpy(). So let's keep it as it is.

I suspect this block of code needs cleanup .

Could you, please, give some indication of what you dislike.

At least the part which looks like ad-hoc implementation of memcpy() ,
any other cleanups are welcome.