I have been working on a program which will use a terminal emulator as the user interface. One thing I am finding is that there seem to be different command formats in the different emulators. I tried using the telnet program that came with Windows. Then I tried Putty. The characters sent from keypresses seem to be different for the various function keys. For example, under telnet, the DEL key is the single code 127 while the Putty program sends a sequence of ESC [ 3 ~ The function keys F1 to F4 are sent as similar sequences in Putty when in "ESC[n~" mode and sends VT52 sequences (e.g. ESC O P) in VT100 mode. The telnet program only seems to send the VT52 sequences. Neither program sends the VT100/52 sequence for the cursor control keys (arrows).
I can't find documentation on the ESC[n~ sequences anywhere. It seems that there is overlap in that a command can be ESC[n~ or ESC[nm~. So the ~ serves as a command terminator which makes the command a bit harder to parse.
I can make the program work with any of these formats, but I would like to understand where they come from and to make sure that I am using them correctly by finding the appropriate documentation. Are the "ANSI" keyboard sequences documented anywhere? I can find docs on the commands *sent* to ANSI terminals, but I only find info on VT52, VT100 etc keyboards. Even if I try to use the VT100 formats, they are not uniformly supported.