5

I am using Ubuntu 19.10 on a Mac, and so I do not have a Delete key on my keyboard.

To emulate that key, I can do Fn + Backspace but I would like to choose another combination of keys like Super + Backspace. Is this possible?

Pablo Bianchi
  • 15,657

3 Answers3

6

This will do the job:

Firstly: edit the XKB /usr/share/X11/xkb/symbols/pc file by running the following command in the terminal:

sudo nano /usr/share/X11/xkb/symbols/pc

Secondly: find this line:

key <BKSP> {    [ BackSpace, BackSpace  ]   };

And comment it out by adding // before it like so:

//key <BKSP> {  [ BackSpace, BackSpace  ]   };

Thirdly: copy and paste the following code below the commented line in secondly above:

key <BKSP> {
    type= "PC_SUPER_LEVEL2",
    symbols[Group1]=  [ BackSpace, Delete ]
};

And save the file.

Fourthly: clear the XKB cache by running the following command in the terminal:

sudo rm -rf /var/lib/xkb/*

Finally: reboot your system to activate your new xkb configuration or reload the new xkb configuration by setting an xkb map layout using the following command in the terminal:

setxkbmap -layout us

and test your new key combination.


This solution should make pressing Super + Backspace work as pressing the Delete key.

To change the combination to Shift + Backspace you can change PC_SUPER_LEVEL2 to PC_SHIFT_LEVEL2 in thirdly above.

Raffa
  • 32,237
1

A command could emulate a specific keystroke. One way to do this is to create a custom shortcut to run xdotool (source) on Settings > Keyboard > Custom Shortcuts:

screenshot

Pablo Bianchi
  • 15,657
0

No, it can't be possible to do it overall, Fn can't be seen as another key, according to this answer :

The Fn is not really comparable. It's a hardware key that's not directly interfaceable by the operating systems. Pressing Fn and another key causes an entirely different code to be sent to the operating system.
Examples for this include XF86AudioMute, XF86Eject and so on. The Operating system can't detect whether Fn is pressed or not.

I had think that it would be possible using gnome-tweakspackage, inside :

Keyboard & mouse -> Additional Layout Options

but no, you can define behavior for each special key (from the basical Ctrl to the old Meta key), but because Fn isn't a software key, you can't change his function.

You can create a custom shortcut to do that Delete emulation, but it required a command.

damadam
  • 2,833
  • You can always use xev to see if the X11 server receives a keypress and which when the key is pressed. If nothing happens when pressing and releasing for instance the Fn button, then you cannot handle it inside X11 (for Linux this means in software) – Thorbjørn Ravn Andersen Nov 25 '19 at 22:15