0

I am using a Bluetooth keyboard with my laptop (running Fedora 33). Very annoyingly, in order to use the F keys, you need to press the "Fn" button, otherwise, they are mapped to special functions.

I am trying to follow this post to remap them, but I seem to be missing something

If I run evtest and, for instance press the F4 key (which is mapped to "copy" if I don't press Fn) I get

Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x4e8 product 0x7021 version 0x11b
Input device name: "SKBWHBT19 Keyboard"
Supported events:
<long list of events>

Event: time 1615808184.907556, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1615808184.907556, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1615808184.907556, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70006
Event: time 1615808184.907556, type 1 (EV_KEY), code 46 (KEY_C), value 0
Event: time 1615808184.907556, -------------- SYN_REPORT ------------

So, clearly, F4 is triggering CTRL+C. I also get the codes for bus 0005, vendor 04e8 and product 7021

How would I go about remapping that to F4?

I created a file called /etc/udev/hwdb.d/bluetooth-keyboard.hwdb with the following content

evdev:input:b0005v04E8p7021
 KEYBOARD_KEY_700e0=fn_f4

Followed by

systemd-hwdb update
udevadm trigger

But this does not work. I am not sure how to input the two scan codes 700e0 and 70006 in there...

I also tried something like

 KEYBOARD_KEY_70004=b

Which should map "a" to "b" but that failed as well

EDIT: following advice by @meuh I added a * at the end of the first line in the hwdb file and this works! However, I can only remap single keys and not combinations. That is, using scan code 700e0 only catches left control, which does not really work as now pressing the F4 key triggers F4 + C. Also, pressing the CTRL key triggers C.

Is there any way of overriding a specific physical key?

nico
  • 568
  • 1
  • 4
  • 12
  • 1
    Dont forget the `*` glob pattern at the end of the match: `evdev:input:b0005v04E8p7021*` – meuh Mar 15 '21 at 20:03
  • I see the keyboard has 3 modes, android, pc, macos. Have you tried these to see if they produce unique codes for the fn keys instead? Even if the key mapping is wrong, you know how to fix that, provided the keys are unique. – meuh Mar 18 '21 at 17:10
  • You need to distinguish between the emulated control-c and a real control-c. This might be possible as the two emulated keystrokes have the same timestamp, whereas normal typing would not. If you are a programmer you could look at the [python-evdev](http://python-evdev.readthedocs.io/en/latest/) library which allows for easy manipulation of evdev input, and also the creation of a new uinput device. – meuh Mar 18 '21 at 17:17
  • Thanks @meuh very interesting suggestions. I may have a go with python-evdev at some point, it may be a fun little project. I think in the meantime I will have to stick to pressing fn! – nico Mar 19 '21 at 07:59

0 Answers0