These are not virtual keycodes.
You are using a terminal.
Terminals operate with a simple 8-bit, sometimes even 7-bit, character stream. For all that a TUI application like nano
knows, there are a serial port, two modems, the PSTN, and an honest-to-goodness DEC VT525 between you and it. All that it sees is that character stream, a terminal device file descriptor, a TERM
environment variable, and record in the terminfo database.
There's no such thing as a control key modifier for an alphabetic key in that character stream. When you write bind ^M
the software is actually understanding that as binding character number 13. That's how the software has to work internally, because that is the actual terminal I/O model that it has to work with. The ^M
is an artefact of the software's command parser, a way to denote character number 13 in configuration commands that you type.
Some operating systems, like FreeBSD, provide common library functions that applications softwares can use in their parsers, to yield uniform semantics for such denotations across applications.
% printf '\x08\x0d' | vis -w ; echo
\^H\^M
%
There are no virtual key codes here, moreover. All of the translation caused by the ⎈ Control modifier key happens in your terminal or terminal emulator, before the characters are transmitted down the (virtual or actual) wire.
It just so happens that your terminal produces character #8 (␈) for ⎈ Control+H and ⌫ Backspace and character 13 (␍) for ⎈ Control+M and Enter. This is entirely up to the terminal/terminal emulator. With many emulators there is a keyboard map of some sort where one can change this. For bona fide DEC VTs, there is in fact an output control sequence, DECBKM, that switches ⌫ Backspace between sending character #8 and sending character #127 (DEL).
Further reading