MacOS – How does macOS detect keyboard? How to manually add a new keyboard

keyboardmacos

I have new keyboard, Logitech MX Keys, 920-009416 = US ISO.
Logitech MX Keys

The keyboard works well, out of box, on Windows 10 and Linux, Manjaro. On macOS there is issue with it.

After plugin on macOS, app Keyboard Setup Assistant opens and try detect my keyboard. The main problem is with keys: tilde~ on the left side of 1 and backslash \ near to z. According to the documentation:

If you are a Windows, Linux and Android user, the special characters will be on the right side of the key:

If you are a macOS or iOS user, the special characters and keys will be on the left side of the keys:

but I want to use tilde to the left of key 1, so I want to use windows/linux layout.
After many attempts with the Assistant, I wasn't able to generate the correct configuration:

$ defaults read /Library/Preferences/com.apple.keyboardtype
{
    keyboardtype =     {
        "10203-5824-0" = 41;
        "45915-1133-0" = 41;
    };
}

I had to help myself Karabiner-Elements and map the keys:
grave_accent_and_tilde(`) with non_us_backslash.

I tried to find out what the code in /Library/Preferences/com.apple.keyboardtype.plist means, but I failed. At first Karabiner could see the keyboard but it was grayed out and I couldn't map keys for it.

The second problem is with adding a new keyboard, new dongle. After this, when I use Keyboard Setup Assistant, the file /Library/Preferences/com.apple.keyboardtype.plist is changing and I have the problem again. I don't know why.

Is it possible to use the same layout as under Windows/Linux? How to manually add a keyboard?
What does the keys layout depend on, §|` and `|\ ?

On Linux, xev returns for left-upper tilde:

KeyPress event, serial 34, synthetic NO, window 0x4000001,
    root 0x139, subw 0x0, time 356984, (-111,112), root:(600,476),
    state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES,
    XLookupString gives 1 bytes: (60) "`"
    XmbLookupString gives 1 bytes: (60) "`"
    XFilterEvent returns: False

and

KeyPress event, serial 37, synthetic NO, window 0x4000001,
    root 0x139, subw 0x0, time 360368, (-107,104), root:(604,468),
    state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
    XLookupString gives 1 bytes: (3c) "<"
    XmbLookupString gives 1 bytes: (3c) "<"
    XFilterEvent returns: False

for "backslash" but I don't use this key.

Best Answer

Have you tried Logitech Options?
It's their custom software and in the specifics tells that it's good also for MX keyboards.