For newer Debian distributions you do not need all this anymore.

> The keyboard file describes the properties of the keyboard. It is read by `setupcon(1)` in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in `/etc/default/keyboard` and it is shared between X and the console. (man keyboard)

In `/etc/default/keyboard` set `XKBOPTIONS="caps:escape"` and then do:

 ~$ sudo setupcon

> Description of all available keyboard models, layouts, variants and options is available in `/usr/share/X11/xkb/rules/xorg.lst`." (man keyboard)