32

my keyboard is damaged, the keyboard key [é] is always pressed and it prevents me from working. On windows I found the software sharpkey to disable the [é] button but on Ubuntu I can't found no solution. On many forums they talks about Xmodmap but I can not work on the terminal as the [é] button is often PRESSED. Please could you give me a solution for that issue. Thanks

1
  • 4
    Do you have ssh enabled? You could use xmodmap from another machine. But have you tried removing the key physically and cleaning under it?
    – Paul
    Jul 2, 2014 at 0:57

5 Answers 5

56

What I would try:

  1. Connect a USB keyboard in there, or get into the machine using ssh.

  2. Open a terminal, and run xev -event keyboard. It will show some stuff on screen. If you omit the arguments, you will notice that it will show some more stuff if you move your mouse, as well.

  3. Then, press the key combination you want to disable [é]. The info in the screen will change, and you will have to look for the keycode value.

  4. Run something like this, changing <value> for the value you got for the keycode in the last step:

    xmodmap -e 'keycode <value>='
    

    For example, if I want to disable the ~ key ( Shift + ` ), I would have to run:

    xmodmap -e 'keycode 49='
    

I have only tried this with more standard keys, like Caps Lock... but I guess it should work with this as well. I hope this helps!

11
  • 3
    But this works only under Xorg. Is it possible to disable on a tty too? Dec 31, 2016 at 0:03
  • 3
    It worked. What if I want to undo this?
    – Vagabond
    Jan 25, 2017 at 14:43
  • 2
    It didn't work for me with esc key, however xmodmap -e 'keycode <value>=NoSymbol' worked Sep 27, 2017 at 11:12
  • 1
    Awesome solution! Any idea how to assign specific "actions" to a keycode? I think they are the keysym
    – jmojico
    May 30, 2020 at 19:37
  • 1
    Any idea how to reverse the process? Oct 17, 2020 at 7:42
4

A simple bash script for my personal use has been uploaded at https://github.com/anitaggu/ikbdop.

To disable internal keyboard of laptop,

./ikbdop.sh detach

To enable the keyboard again

./ikbdop.sh attach

A brief howto is also uploaded at YouTube

1
  • That does not answer the question of the OP, he asked about disabling one key, and not the internal keyboard. and the attach part of your script does not work
    – Normal
    Jul 22 at 3:33
0

It simply looks good and simple using xmodmap -e 'keycode 117='

I use this to disable the page down key and it works. Why don't you try this once . Do it ..

1
  • How is this better than accepted answer?
    – Toto
    Apr 9 at 8:16
0

1) Detect the keycode for the keyboard key you want to disable:

Method A:

This method only works if you're trying to disable regular keys, not F1, F2, F3....etc

As you're reading this answer, right-click anywhere on my answer -> click Inspect Element or Inspect, paste this code into the console tab and press enter:

window.addEventListener('keypress', (e) => console.log(e.keyCode) )

Click again on my answer with your mouse left button, and press the key you want to disable, you'll notice a number printing in the console of the browser.

copy that number and follow the next step.

Method B:

this method should work with every key on your keyboard open the terminal, and use the xev utility as follows:

$ xev -event keyboard

a small window will open, press the key on your keyboard that you want to disable, and close the small window, you'll notice output on your terminal, among this output, you'll see something like keycode 93. copy the keycode for that keyboard key and follow the next step.

2) Disable the key:

open the terminal, and use the xmodmap utility as follows:

xmodmap -e 'keycode <value>='
  • in place of the <value> above, replace it with the keyCode you got from step 1 method A or B.
-1

You can also change the keyboard for new one. It is possible to order a keyboard for your particular laptop on the net and it comes by post envelope somewhere from China.

You can also just disconnect you keyboard and use external USB one. It is easy to open your laptop and disconnect a little cable going from the keyboard to the motherboard.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.