It worked by editing xkb files. I decided to edit pt (Portuguese) as the layout is ok for me and I don’t mind if I mess it up.
So on the phone I edited /usr/share/X11/xkb/symbols/pt
There are different sections in the file; one would normally create another layout variant, but I don’t know how to tell SFOS to use the specific variant. So I edited the first group called “basic” to make sure SFOS would use it.
xkb_symbols "basic" {
include "latin(type4)"
name[Group1]="Portuguese";
// below my additions
// main key Shift Alt-gr Alt-gr shift
key <TLDE> { [ atilde, Atilde, backslash, bar ]};
key <AE01> { [ aacute, Aacute, 1, exclam]};
key <AE02> { [ agrave, Agrave, 2, at]};
key <AE03> { [ eacute, Eacute, 3, numbersign]};
key <AE04> { [ egrave, Egrave, 4, otilde]};
key <AE05> { [ ccedilla, Ccedilla, 5, percent]};
key <AE06> { [ masculine, ordfeminine, 6, quotedbl]};
key <AE07> { [ uacute, Uacute, 7, multiply]};
key <AE08> { [ iacute, Iacute, 8, parenleft]};
key <AE09> { [ oacute, Oacute, 9, parenright]};
Of course this disposition is weird for everybody other than me, but it’s similar to what I use on my fixed computer keyboards and I got used to it. It gives direct access to most acute and grave accented letters on the 1-9 keys. I would normally use numbers on the numerical pad (full sized keyboard), but my BT keyboard is a small one so I put the numbers and the some of the regular symbols on Alt-Gr.
I restarted the phone to make sure the changed made effect.