2

I suspect this can't be done, but I would like to disable a specific key (namely '6' on the top row) on a specific keyboard (namely my laptop internal keyboard). The key is spamming 6s but is otherwise working (and I've ordered a replacement but it will take a long time due to location). I am mostly using a USB keyboard but it is a pain to disable an entire keyboard (using xinput --float) just for one key.

So: is it possible to disable a specific key on a specific keyboard? I am using Kubuntu 19.10 although I suspect that is not important for this.

2
  • 2
    It should be possible, try to intercept first keyboard code, and then rewrite the value. These are your friends: linux.die.net/man/1/xev and linux.die.net/man/1/xmodmap Commented Feb 8, 2020 at 1:56
  • 1
    But how do you do that for a specific keyboard i.e. only disable it on my laptop keyboard and not on my USB keyboard? Commented Feb 8, 2020 at 3:32

1 Answer 1

2

I would try this:

Use xev to find the keycode of the 6 key on your keyboard, "on mine it is 15". Then use xmodmap -e "keycode 15 = " where 15 is the number you found with xev. This will map that key to nothing. If that ends up not being persistent after reboot add that command to your startup apps.

If wanting for just one keyboard:

  • Install xkbcomp 1.2.0
  • Use xinput list find the specific keyboard id
  • Find the keycode for the key with xev.

FURTHER instructions at the link... https://superuser.com/a/869064/964775

  • To undo this operation you must remember or write down what xev gave you for the key and then just xmodmap it back to that.

  • I am fairly certain you could add this to your .profile or .bashrc file and have it be set for all terminals as well.

4
  • I ended up doing it a slightly different way as this method didn't work for some reason, but got me on the right track :) Did something like: miek.nl/2014/october/28/xmodmap-is-dead but using the -i (remote_id) flag. Commented Feb 8, 2020 at 15:47
  • It would be good to add a way to undo the change. Commented Aug 20, 2023 at 9:05
  • I have the issue with spamming <. It seems to be keycode 94. Interestingly, xmodmap -e "keycode 94 = " seems not to have any effect (Ubuntu 20.04, Thinkpad T460p) Commented Aug 20, 2023 at 9:06
  • It seems to work only for the current terminal. I also tried xmodmap -e 'keycode 94=NoSymbol' Commented Aug 20, 2023 at 9:28

You must log in to answer this question.

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