Swapping keys AltGr and Space in Kali - Firefox is not affected

I've actually made it work even with xkeymap, I leave it here as a different answer because the method is strictly different from my previous solution.

Maybe you've missed some occurrence of AltGr usage.

Trying to mimic your setup, I've exported the current configuration file with the command xkbcomp $DISPLAY current.xkb and edited it by removing all ISO_Level3_Shift, LVL3 and Mod5 occurrences.

Precisely, what I've deleted is:

interpret ISO_Level3_Shift+AnyOf(all) {
    virtualModifier= LevelThree;
    useModMapMods=level1;
    action= SetMods(modifiers=LevelThree,clearLocks);
};
interpret ISO_Level3_Shift+AnyOfOrNone(all) {
    action= SetMods(modifiers=LevelThree,clearLocks);
};
key <LVL3> {
    type= "ONE_LEVEL",
    symbols[Group1]= [ ISO_Level3_Shift ]
};
key <RALT> {
    type= "ONE_LEVEL",
    symbols[Group1]= [ ISO_Level3_Shift ]
};
modifier_map Mod5 { <LVL3> };

Then I've inserted:

key <LVL3> {[space]};
key <RALT> {[space]};

This edited configuration can be tested by loading it with

xkbcomp new_conf.xkb $DISPLAY

Tags:

Xkb

Kali Linux