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
-
4Do 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 02 '14 at 00:57
7 Answers
What I would try:
Connect a USB keyboard in there, or get into the machine using ssh.
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.Then, press the key combination you want to disable [é]. The info in the screen will change, and you will have to look for the
keycodevalue.Run something like this, changing
<value>for the value you got for thekeycodein 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!
-
3But this works only under Xorg. Is it possible to disable on a tty too? – paulodiovani Dec 31 '16 at 00:03
-
3
-
2It didn't work for me with esc key, however `xmodmap -e 'keycode
=NoSymbol'` worked – YasserKaddour Sep 27 '17 at 11:12 -
what about doing the same in terminal (/dev/vty*) w/o (or before starting) X ? – Dec 17 '17 at 18:21
-
How to make this work every time xorg starts? So after logout/login and reboot it keeps on working? – sscarduzio Mar 13 '20 at 12:18
-
1Awesome solution! Any idea how to assign specific "actions" to a keycode? I think they are the keysym – jmojico May 30 '20 at 19:37
-
1
-
-
This only affects terminal for me, which is the desired behavior. It does not impact a web browser, for example. I made it persistent by putting the commands in `~/.bashrc`. – Jeff Hammond Jan 12 '21 at 18:41
-
@JeffHammond for me it works for most programs, including the browser and the terminal. The only program that it didn't work for was VS Code. By the way, thanks for the tip about adding these commands to `~/.bashrc` to make the changes stick! – waldyrious Aug 18 '21 at 22:04
-
This worked for me too, I needed to disable the + key which was typing by itself, so I ran: xmodmap -e 'keycode 86=NoSymbol' – Don Flannagan Dec 14 '21 at 14:44
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
-
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 '22 at 03:33
None of the above-mentioned method works on Wayland. I am not sure about other desktop environments, but the easiest way to disable a specific key on a specific keyboard on sway-wm is to use keyd. It however requires the terminal and I would suggest you to use USB keyboard after removing the physical keyboard till this is done.
- Clone keyd from GitHub, build it and start the daemon.
git clone https://github.com/rvaiya/keyd
cd keyd
make && sudo make install
sudo systemctl enable keyd && sudo systemctl start keyd
- Find the name of the problematic key and keyboard.
Run
sudo keyd monitorto get something like this:
device added: 0fac:0ade keyd virtual keyboard (/dev/input/event20)
device added: 03f0:5341 PIXART HP Wireless Keyboard and Mouse Consumer Control (/dev/input/event18)
device added: 03f0:5341 PIXART HP Wireless Keyboard and Mouse (/dev/input/event17)
device added: 03f0:5341 PIXART HP Wireless Keyboard and Mouse (/dev/input/event7)
device added: 06cb:7f13 Synaptics TM3253-001 (/dev/input/event5)
device added: 0001:0001 AT Translated Set 2 keyboard (/dev/input/event0)
keyd virtual keyboard 0fac:0ade enter up
keyd virtual keyboard 0fac:0ade kp5 down
I have got two keyboards attached. One is PIXART HP Wireless with 03f0:5341 and another AT Translated Set 2 keyboard with 0001:0001. These codes are what keyd uses to recognize your keyboards. So make note of the code and the key name for the next step. The last column gives the key names. Here, I left enter and pressed down kp5.
- Edit the file
/etc/keyd/default.confto:
[ids]
0001:0001 #code of attached keyboard from earlier
[main]
kp5 = noop #Ignore the key 'kp5'
- Finally,
sudo keyd reload
To disable a specific key from all keyboards. Edit the default.conf mentioned above as
[ids]
*
[main]
kp5 = noop
- 46
- 3
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
- 1
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.
- 101
- 2
Using the above method, I got
xmodmap: commandline:1: bad keycode command (missing keysym list)
I had to enter:
xmodmap -e 'keycode 133=NoSymbol'
(This keycode disables the b****y irritating 'Windows' key.
- 1,875
- 11
- 12
- 19
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 15 '22 at 18:22
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.
- 2,156
- 1
- 15
- 12