How to disable specific Keys on keyboard?

Hi,I’m a newbie on manjaro

Here’s my problem…my laptop has an issue with It’s keyboard… The Z button is broken…It’s spamming…zzzzzzzz whenever i write anything… Is there any way to disable this key…and assign any other key for this purpose??

Manjaro gnome…latest build

So when you press Z it gets stuck? Have you checked under the keys for debris/gunk?

There are several ways to swap keys. You can use xmodmap or xkbcomp to dump the current config, edit, and re-apply. However this won’t work in a TTY ie the console, you’ll need to configure that separately, see the second link.

The last link would work for both.

Xorg/Keyboard configuration - ArchWiki
Linux console/Keyboard configuration - ArchWiki
xmodmap - ArchWiki
X keyboard extension - ArchWiki
Map scancodes to keycodes - ArchWiki

Here’s an example with xmodmap.

# dump config
xmodmap -pke > ~/.xmodmap

# edit file
gedit ~/.xmodmap

# This is z
keycode  52 = z Z z Z guillemotleft less guillemotleft
# and insert
keycode  118 = Insert NoSymbol Insert

# change like so
keycode  52 =
keycode  118 = z Z z Z guillemotleft less guillemotleft

# save file

# apply config, it will take a few seconds
xmodmap ~/.xmodmap
2 Likes

I can’t quite understand…

Can u plz give me step by step direction?? I’m a newbie here

I want to disable Z button and use numpad 6 for the Z purpose…

Plz give me step by step direction

I’ve been playing around with mapping scancodes to keycodes, it’s the better option so we’ll do it this way.

First open a terminal and install evtest.

sudo pacman -S evtest 

You will be asked for your password, type it in and press Enter(you won’t be able to see what you’re typing). Then confirm you want to install by pressing Enter again.

Next run evtest.

sudo evtest

It will display a list of devices and their corresponding event numbers. Find your keyboard in the list, and type the event number followed by Enter.

Press Z and you should see something like this.

Event: time 1654467466.446422, type 4 (EV_MSC), code 4 (MSC_SCAN), value 2c
Event: time 1654467466.446422, type 1 (EV_KEY), code 44 (KEY_Z), value 1
Event: time 1654467466.446422, -------------- SYN_REPORT ------------

We need the scancode (the value field for MSC_SCAN) which in my case is 2c, yours may be different. Also get the scancode for Numpad 6 which for me is 4d.

Event: time 1654505070.826956, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4d
Event: time 1654505070.826956, type 1 (EV_KEY), code 77 (KEY_KP6), value 0
Event: time 1654505070.826956, -------------- SYN_REPORT ------------

Press Ctrl + C to exit.

Then create the configuration file.

sudo nano /etc/udev/hwdb.d/10-remap-z.hwdb

Copy/paste this.

evdev:atkbd:dmi:*             # built-in keyboard: match all AT keyboards for now
 KEYBOARD_KEY_2c=reserved     # bind z to nothing
 KEYBOARD_KEY_4d=z            # bind kp6 to z

If necessary edit the scancodes (2c, 4d) to match yours. Make sure the KEYBOARD_KEY lines are indented by exactly 1 space.

Press Ctrl + X followed by Y and then Enter to save and exit.

Run these commands.

sudo systemd-hwdb update
sudo udevadm trigger

Test your keys. :slight_smile:

Thank you so much sir,for ur kind help…it worked…grateful to u

1 Like

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.