I'm interested in writing a terminal emulator for fun. I roughly understand the division of labor between the shell and the terminal emulator from this post: What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?, but I haven't been able to find a full, detailed description of what the mapping between keypresses and control characters needs to be, what sorts of syscalls need to be made to acquire and interact with a pty, etc.
Is there a man page I should look at? Where can I find a full, compete spec for a terminal emulator in Linux?