18

My new laptop (Dell Inspiron 5578) has no numeric pad. Many laptops without dedicated numpad keys have numpad accessible through Fn, but not this one. When I run xev and try to use traditional Fn combos (e.g., Fn+J for 1), it sees no event. And the numbers are not even on the labels.

AFAIU, I cannot create any shortcut with the Fn key, because Fn is not passed to the OS. But I could theoretically use Alt_L+Super_L instead. The question is how to do it properly. I'd prefer to do it on a lower level than keyboard layout in order to work well with all the VMs, even with non-Linux ones.

Environment: Qubes OS. The host part is based on Fedora.

I've tried:

  • Bind an xdotool command via Xfce key shortcut. This produces various weird results: The command (xdotool key KP_1 and variations) usually works OK, but not when invoked by shortcut. When invoked by shortcut, the problem probably is that modifier keys are pressed at the time. I've tried various modifications (--clearmodifiers, keyup for modifiers etc.), none of them works well.
  • Do the same with autokey. I got some freezes of autokey.

Non-solutions:

  • Use external numpad/keyboard: While I have a numpad (sort of) on my external keyboard, I'd like to have one even on the internal one, e.g., when travelling and it is impossible or at least uncomfortable to use the external keyboard.
  • Use number row: In Czech layout, the number row is used primarily for accented letters. The layout I use (extracs variant of CShack) does not have numbers in the “number row” at all.
  • Buy a different laptop: It was hard to find a laptop satisfying my various requirements.
8
  • 1
    Read up on xkb, add a custom Alt-L + Super-L level. Also run evtest to look for a Fn event, and if that doesn't work either, look at the HID descriptor and raw HID event. See dmesg to find associated hid devices.
    – dirkt
    Commented May 22, 2017 at 15:19
  • @dirkt Using XKB looks like defining a custom keylayout. Which is better than nothing, but it is not a preferred solution, as I would have to do the same for every VM (or VM tempolates) and this is not going to work under non-Linux VMs. I'll try evtest, but I am unsure if it will work with keyboard that is being used.
    – v6ak
    Commented May 22, 2017 at 15:38
  • Are you attached to Alt_L + Super_L? You could use AltGr or Shift + AltGr with xmodmap(1)
    – Fox
    Commented May 22, 2017 at 17:17
  • If your VM (which one?) doesn't pass on X events, but insists on direct keyboard passthrough, you can probably fake a keyboard by making your own /dev/input/eventX or HID source. This will require programming. But if it works with xdotool, it should work with xkb or xmodmap. And yes, assigning a single key to Mode_Switch or ISO_Level3_Shift (AltGr by default) will be easier.
    – dirkt
    Commented May 22, 2017 at 17:38
  • 1
    The problem with AltGr or AltGr+Shift is it is already used. I don't insist on Alt_L+Super_L, but it looks as the best choice: They are next to each other on the internal keyboard and there is a little chance to hide some keyboard shortcut. And they can be pressed with left hand. So, it looks like ideal combination,
    – v6ak
    Commented May 22, 2017 at 18:30

2 Answers 2

1

You could try kbindkeys, numlockx and a slightly customized keyboard.

Once you install xbindkeys, you have to run it. It will tell you what to do to create the basic configuration.

Then you use xbindkeys -k to identify the key and modify the configuration file (it's all documented in the default configuration file).

At last, I suggest you run xbindkeys -v -n to see if everything works. If it does, you can run xbindkeys for that session and maybe add it to your startup scripts.

In my case, the Windows key (right) does the binding, and my ~/.xbindkeysrc is:

"numlockx toggle"
    m:0x10 + c:134
    Mod2 + Multi_key

Now you can add the mappings. You will use the fifth and sixth levels (numlock and shift+numlock).

At the top of /usr/share/X11/xkb/symbols/cz, right after:

default  partial alphanumeric_keys

add this snippet:

xkb_symbols "with_numpad" {
    include "cz(basic)"

    key.type[Group1] = "EIGHT_LEVEL_ALPHABETIC_LEVEL_FIVE_LOCK";
    key <AC07>  { [         j,          J,   apostrophe,     NoSymbol , 1, 1] };
    key <AC08>  { [         k,          K,      lstroke,     NoSymbol , 2, 2] };
    key <AC09>  { [         l,          L,      Lstroke,     NoSymbol , 3, 3] };
};

Now, when you press the window key (right), xkeybind will set numlock, which in turn will make J,K,L and so on return 1,2,3.

Last step, set the new keyboard with:

 setxkbmap cz with_numpad
5
  • I have tried xbindkeys. I can set an action for some key combinations it might bring a solution. It is certainly something similar to what I have tried with Xfce key shortcuts and autokey. The problem is rather what action to use. Num lock is not what I need. I want to have some modifier key that changes JKL to 123, UIO to 456 and so on. I have tried xdotool (as mentioned in the original post), but with no luck.
    – v6ak
    Commented May 26, 2020 at 6:57
  • Ok, I get it, I'll try to expand the answer, how are you setting the Czech layout? (command, tool,...) Commented May 26, 2020 at 15:26
  • I use setxkbmap.
    – v6ak
    Commented May 27, 2020 at 6:30
  • Ok, I think the new answer covers it. Commented May 27, 2020 at 23:54
  • Well, this is similar to my current solution (I use a modifier key instead of numlock), but it requires a custom layout. As explained in a comment to the other answer, I would like to avoid custom layout, as it is not fully universal with all the cases.
    – v6ak
    Commented Jun 3, 2020 at 23:52
0

I think the right way to go here is to create your own keyboard layout. Indeed you will have to do so for every VM and every operating system but you only have to deploy it on your template VMs.

Making them is actually not that difficult, depending on your point of view even surprisingly easy. For linux you are on the right track. For windows just use autohotkey.

(Or just ditch your current layout and try neo2. It's optimized for German but the layout in general is excellent and you get out of the box support on linux and a pretty good autohotkey implementation on windows. I've been using it for years. The biggest downside is that the layout is so exotic you often have to customize shortcuts in programs to make them usable again, e.g. hjkl in vim is totally fucked up.)

3
  • I have made a custom layout, but it is still quite imperfect. It would be imperfect even if it had a Windows version. Installation to templateVMs is not an issue, but other machines are tricky. First, RDP does not honour my local keyboard layout. Second, it is some overhead for various short-lived Windows VMs (e.g., IE VMS).
    – v6ak
    Commented Oct 18, 2018 at 11:43
  • @v6ak Short lived VMs should inherit the setup of the template so that should not be an issue.
    – Franklin
    Commented Oct 18, 2018 at 12:04
  • That's true for template-based VMs, but not for VMs you have just downloaded. And also not for remote VMs that are not managed by you. I am relatively OK with standard US layout (when I don't need diacritics, it is mostly compatible with CShack), but using number row is not much natural for me.
    – v6ak
    Commented Oct 18, 2018 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .