Having more fun, in /etc/default (in Debian anyway) are files keyboard and locale among others. I changed my locale to en_GB.UTF-8 as a test but in the keyboard file XKBLAYOUT is still "us". I thought those were linked. At one point I had a GB layout and the # key printed the Pounds Sterling symbol. XKBVARIANT and XKBOPTIONS are both empty (""). But XKBMODEL is pc105, so that's where that comes from. There are 78 keys, not 105.
Try apropos keyboard. There's an xkbprint (with a man page) which is supposed to print the layout for any compiled .xkm file. But locate doesn't find any. You can enable symbols (or codes?). Man page from 1998 though. This stuff has been around for 40 years but much has been gutted.
There's xkbcomp which is a compiler that makes .xkm files from .xkb. /usr/share/X11/xkb might have some, but no, there are none. Obsolete I guess.
In Debian xev is in a package called x11-utils. There's another, x11-xkb-utils hat has xkbprint, also xkbwatch which lights up on modifier keys.
Keycodes are supposed to be changeable, scancodes shouldn't be, they should come from the hardware. They get processed through the mapping and become keycodes. Except I've also seen something about sometimes the mapping provides scancodes by working backwards. I've got to open this thing up to fix the hinge sometime soon. Usually there are rows of wires going one way and columns of wires going the other, when you press a key it connects a row to a column, that should give a scancode.
Like this: https://www.dribin.org/dave/keyboard/one_html/ What's wired isn't going to be changeable by software.
One of my first computers was an Interact 8080, which had really cheap keys that acted up after a month or so. So I got this industrial grade surplus keyboard and hooked it up on a big fat cable. Painted the keycaps white, lettered them with ink, put varnish over them. I learned how keyboards work.
Try apropos keyboard. There's an xkbprint (with a man page) which is supposed to print the layout for any compiled .xkm file. But locate doesn't find any. You can enable symbols (or codes?). Man page from 1998 though. This stuff has been around for 40 years but much has been gutted.
There's xkbcomp which is a compiler that makes .xkm files from .xkb. /usr/share/X11/xkb might have some, but no, there are none. Obsolete I guess.
In Debian xev is in a package called x11-utils. There's another, x11-xkb-utils hat has xkbprint, also xkbwatch which lights up on modifier keys.
Keycodes are supposed to be changeable, scancodes shouldn't be, they should come from the hardware. They get processed through the mapping and become keycodes. Except I've also seen something about sometimes the mapping provides scancodes by working backwards. I've got to open this thing up to fix the hinge sometime soon. Usually there are rows of wires going one way and columns of wires going the other, when you press a key it connects a row to a column, that should give a scancode.
Like this: https://www.dribin.org/dave/keyboard/one_html/ What's wired isn't going to be changeable by software.
One of my first computers was an Interact 8080, which had really cheap keys that acted up after a month or so. So I got this industrial grade surplus keyboard and hooked it up on a big fat cable. Painted the keycaps white, lettered them with ink, put varnish over them. I learned how keyboards work.
Code:
From man 7 X:
KEYBOARDS
The X keyboard model is broken into two layers: server-specific codes
(called keycodes) which represent the physical keys, and server-inde‐
pendent symbols (called keysyms) which represent the letters or words
that appear on the keys. Two tables are kept in the server for con‐
verting keycodes to keysyms:
modifier list
Some keys (such as Shift, Control, and Caps Lock) are known as
modifier and are used to select different symbols that are at‐
tached to a single key (such as Shift-a generates a capital A,
and Control-l generates a control character ^L). The server
keeps a list of keycodes corresponding to the various modifier
keys. Whenever a key is pressed or released, the server gener‐
ates an event that contains the keycode of the indicated key as
well as a mask that specifies which of the modifier keys are
currently pressed. Most servers set up this list to initially
contain the various shift, control, and shift lock keys on the
keyboard.
keymap table
Applications translate event keycodes and modifier masks into
keysyms using a keysym table which contains one row for each
keycode and one column for various modifier states. This table
is initialized by the server to correspond to normal typewriter
conventions. The exact semantics of how the table is inter‐
preted to produce keysyms depends on the particular program,
libraries, and language input method used, but the following
conventions for the first four keysyms in each row are gener‐
ally adhered to:
The first four elements of the list are split into two groups of
keysyms. Group 1 contains the first and second keysyms; Group 2 con‐
tains the third and fourth keysyms. Within each group, if the first
element is alphabetic and the the second element is the special keysym
NoSymbol, then the group is treated as equivalent to a group in which
the first element is the lowercase letter and the second element is the
uppercase letter.
Switching between groups is controlled by the keysym named MODE SWITCH,
by attaching that keysym to some key and attaching that key to any one
of the modifiers Mod1 through Mod5. This modifier is called the
``group modifier.'' Group 1 is used when the group modifier is off,
and Group 2 is used when the group modifier is on.
Within a group, the modifier state determines which keysym to use. The
first keysym is used when the Shift and Lock modifiers are off. The
second keysym is used when the Shift modifier is on, when the Lock mod‐
ifier is on and the second keysym is uppercase alphabetic, or when the
Lock modifier is on and is interpreted as ShiftLock. Otherwise, when
the Lock modifier is on and is interpreted as CapsLock, the state of
the Shift modifier is applied first to select a keysym; but if that
keysym is lowercase alphabetic, then the corresponding uppercase keysym
is used instead.