Anyone have experience with kitty remote control and send-text?

I’m trying to write a quick little plugin for interacting with kitty from neovim. Sending usual text works fine but I want to try sending arbitrary keycodes, either by translating “” to “^[[A” or perhaps even mirroring all keypresses until or . Through experimentation I’ve found nvim_replace_termcodes is not the correct function to use for the first one, unless I’m missing something. Is there a builtin function that can do this for me? Any libraries?