A trip through historyYou are assuming that Vim handles e.g. the network traffic of a remote session directly. It doesn't.
Have a look at the name of the client software you mentioned yourself -- putty. That's actually PuTTY. The "TTY" in there stands for
teletype. Originally, you were actually accessing a computer (the kind that filled a whole room) through a teletyper. Which means you had no "screen", you interacted with the computer a line at a time.
1966 - QED, "quick editor", Butler Lampson / L. Peter Deutsch for the SDS 940. Ken Thompson ported QED to the Compatible Time-Sharing System, adding regex support, and later wrote a version for Multics in BCPL. (One of the QED regex commands added was "g/<re>/p" -- global, regular expression, print -- which would print all lines ("globally") from the current file which matched the regular expression. This would later become the stand-alone command "grep".)
1971 - ED, "editor", Dennis Ritchie (with Ken Thompson) for the PDP-7. (We just had "grep"... when you want to apply ED commands to a stream of data, there is a standalone for that as well -- "sed".)
1976 - EM, "editor for mortals", George Coulouris (if you compare today's Vim commands with the somewhat clunky syntax of sed commands, thank George for doing most of that transitional work).
1978 - EX, "editor extended", Bill Joy, for BSD
When video displays became more common, things like the
VT100 were used as "user terminals", or just terminals, instead of teletypers. This allowed new things to be done.
1980 - curses library, Ken Arnold, for BSD
The curses library ("cursor optimization") allowed access to the whole screen of a video terminal, and made a new kind of application possible. (Of course, one of the first such application was "
rogue", the terminal/ASCII-based adventure game...)
Bill Joy added a mode to EX that allowed the whole screen to be used for displaying text buffers; this mode was entered via the EX command ":visual", which could be abbreviated ":vi". Eventually, that mode became so popular that a shortcut was created to start EX directly in visual mode -- vi was born.
1987 - Stevie, a vi-clone for Atari ST, ported to Unix, OS/2 and Amiga by Tony Andrews.
1991 - Vim, Bram Moolenaar, for Amiga, adding many vi features that were missing from Stevie, and later much more. Eventually ported basically everywhere.
---
When you today start PuTTY, gnome-terminal, xterm or whatever, what you are actually using is a
terminal emulator (yes, the "terminal" software we use in 2018 re-enacts a 1978 video terminal as an extension of a 1968 teletype).
Vim does not care whether your session is local or remote. Actually, unless you are actually using the
console on a Unix / Linux / BSD machine, you are going through X11, at which point your session
is remote for all practical purposes as far as Vim is concerned (the X11 server is providing your graphic card's services to X11 clients, which might be local or remote). All the network traffic and keystroke handling is done by lower layers, long before Vim "sees" them.
So now you can refine your question, and ask how those
lower layers distinguish between "Home" and "<Esc> O H", to which I can only say...
...I have no idea.