How to type home, end, insert, delete on the Reform keyboard?

Hey all,

I’m new to Reform and wondering if it’s possible to type certain keys on the keyboard, namely: HOME, END, INSERT, DELETE, and PrintScreen/SysRq (including the Alt+SysRq commands for Linux kernel)? Or how do I create new key combinations to emulate those keys? Thanks!

Welcome! There are two possibilities:

  1. Use xkb to modify the keymap, see: https://community.mnt.re/t/compose-umlauts-on-us-keyboard/153/3\

  2. Change the keycodes/matrix itself, which requires rebuilding and flashing the keyboard firmware (it’s pretty easy though): reform2-keyboard-fw/Keyboard.c · master · Reform / reform · GitLab

For 2, there is no code yet to allow for different layers yet, i.e. it’s not possible to send a different scancode when a modifier is pressed. So 1 is the cleaner method. I wish there was a good config tool for xkb, that would make it much easier.

1 Like

Will udev remap work?
eg. like I’ve remapped keys on my mouse:

$ grep -Ev '^(#|$)' /etc/udev/hwdb.d/604-g-remap.hwdb 
evdev:input:b0003v046Dp4085e0111*
 KEYBOARD_KEY_7001e=f7
 KEYBOARD_KEY_7001f=f8
 KEYBOARD_KEY_70020=f9

It will work with the keyboard, but it looks like it’s not possible to add new key combinations to enter missing keys using this method, or am I missing something?

Well, you have plenty of keys defined in /usr/include/linux/input-event-codes.h, any of those could be mapped. So yes, you cannot do combination, but you can generate any suitable keycode and handle it then by sway, mapping to a script (a hotkey effectively). Hotkeys won’t help when sway is not available of course (eg hangs or died).

1 Like

So, after following the XKB configuration rabbit hole for a while, I’ve ended up with the following settings:

xkb_keymap {
    xkb_keycodes { include "evdev+aliases(qwerty)" };

    xkb_types {
        include "complete"
        virtual_modifiers Hyper;
        type "HYPER" {
            modifiers = Hyper;
            map[Hyper] = Level2;
            level_name[Level1] = "Base";
            level_name[Level2] = "Hyper";
        };
    };

    xkb_compat { include "complete" };

    xkb_symbols {
        include "pc+us+inet(evdev)"
        include "compose(menu)"
        
        key <RWIN> { [ Hyper_L ] };
        modifier_map Mod5 { <HYPR> };
        
        key <LEFT> {
            type = "HYPER",
            symbols[Group1] = [ Left, Home ]
        };
        
        key <RGHT> {
            type = "HYPER",
            symbols[Group1] = [ Right, End ]
        };
        
        key <RTRN> {
            type = "HYPER",
            symbols[Group1] = [ Return, Insert ]
        };
    };

    // xkb_geometry  { include "pc(pc105)" };
};

This maps Hyper+Left/Right to HOME and END and unmaps Hyper from existing Super keybindings by remapping it to Mod5. Additionally, compose key on the «…» key next to Ctrl is enabled.

Unfortunately, I could only bind Hyper combinations with an extra virtual modifier defined in xkb_types section above - this either requires an additional types file along with the symbols file or saving XKB settings in a single xkbcomp-like keymap source file as above.

This file can also be loaded in sway using xkb_file input command as follows:

input "1003:8258:MNT_Reform_Keyboard" xkb_file /path/to/reform.xkb
1 Like

Thank you for your research. Could you please help me? Is there any way to modify this .xkb file to add multiple languages layouts and toggle combination?

For example, if I change
include "pc+us+inet(evdev)"

to
include "pc+us+ru:2+inet(evdev)"

Where can I add a layout toggle combination (like in "setxkbmap -optioon “grp:alt_shift_toggle”)?

1 Like

It should be enough to add the following statement to xkb_symbols section:

include "group(win_space_toggle)"

or similar. The complete list of available toggles can be found in /usr/share/X11/xkb/symbols/group.

2 Likes

Yay, it works! Thanks a lot.

2 Likes