I want to disable the number-part of the keys on the top-row of my keyboard. I only use the numberpad to the right of my keyboard to enter numbers. I get VERY frustrated when i want to type a symbol which appears on the top-row (e.g. 4 and $) and get "4" instead of "$". The proper answer is to take typing lessons but I'm too old to do that and totally refuse to do so. There must be a way that I can restrict my top-row to be symbols only? Answers/tips please?
Ubuntu – Disable number keys on top-row of keyboard
keyboardkeys
Related Solutions
There is a gui tool to remap keys. It is called dconf-tools (install via apt). Under org -> gnome -> desktop -> input-sources there are xkb-options. I used this to switch escape and capslock.
EDIT: go to /usr/share/X11/xkb/symbols . There you'll find abbreviations for different languages. Open your language with sudo nano ... In the file you'll see lines like: '1, exclam, ...' just put the command for the symbol first and the number second and it will be switched around.
Are keyboard multimedia keys different?
Yes, these keys are a little different. They might report a single key code or multiple key codes when pressed with other keys like Fn for example. Furthermore, it is oftentimes difficult to identify their key codes with utilities like xev
. This depends on the keyboard's manufacture's configuration.
Multimedia keys, usually, have their key codes configured with XF86 key names. These names differ but start with XF86
like XF86MonBrightnessUp
and XF86MonBrightnessDown
and so on.
How to disable/reconfigure keyboard multimedia keys?
XKB
Method
The easiest method is to edit the XKB configuration file like so:
Edit the XKB
/usr/share/X11/xkb/symbols/pc
file by running the following command in the terminal:sudo nano /usr/share/X11/xkb/symbols/pc
Find lines that contain
XF86
like so:key <KEY_CODE> { [ XF86MonBrightnessDown ] };
Comment them out by adding
//
before them like so://key <KEY_CODE> { [ XF86MonBrightnessDown ] };
Save the file and exit the editor by pressing Ctrl + X then press Y.
Clear the XKB cache by running the following command in the terminal:
sudo rm -rf /var/lib/xkb/*
Reboot your system to activate your new XKB configuration or alternatively you can avoid reboot and try to reload the new XKB configuration by setting an XKB map layout using the following command in the terminal:
setxkbmap -layout us
Test your keys.
If the keyboard multimedia keys are configured by the manufacturer to report a single key code, the above solution might disable them and leave the keys free to be used for other purposes.
If, however, this is not the case, then you will need to deal with xmodmap
.
xmodmap
Method
The xmodmap
method is a little different and you cannot just disable multimedia keys using this method and assign them to nothing like so xmodmap -e 'keycode Number ='
because this, oftentimes, will render them unusable so you will need to reassign them to the desired functions. You will also need to put in action some mechanism to maintain your changes between reboots and logouts/logins.
To implement this method, please follow the steps below:
Show the current keyboard map by running the following command in the terminal:
xmodmap -pke
Inspect the output and identify lines that contain
XF68
right after the=
sign like so:
keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown
The above line, for example, shows that the key with code number 232 is currently configured to trigger XF86MonBrightnessDown
which will decrease the monitor's brightness and you can change this behavior by assigning a different value to it like so xmodmap -e 'keycode 232 = New_Value'
. For example to assign the F11 functionality to this multimedia key, please run the following command in the terminal:
xmodmap -e 'keycode 232 = F11'
The new functionality will be effective immediately. This change in functionality will, however, be lost after reboot or logout/login.
Notice: It might be helpful to run the acpi_listen
command in the terminal and monitor the output as you press the actual physical key then compare it to the output you got from xmodmap -pke
so that you confirm the key code is for the one you want. You can also try the xev
utility but, unfortunately it will not always return a key code when dealing with multimedia or vendor specific keys.
To preserve the change after reboots and logouts/logins, you will need to do the following:
Create and edit a script file in your home directory by running the following command in the terminal:
nano ~/.Modify_Multimedia_Keys.sh
Add this
#!/bin/bash
in the first line then add yourxmodmap -e 'keycode Number = New_Value'
commands below the first line ( each command in a single new line ) like so:
#!/bin/bash
xmodmap -e 'keycode 232 = F11'
xmodmap -e 'keycode 122 = F2'
Save the script file and exit the editor by pressing Ctrl + X then press Y.
Make the script file executable by running the following command in the terminal:
chmod +x ~/.Modify_Multimedia_Keys.sh
Make the script file execute at each start-up either by adding it to your Startup Applications through the GUI or by placing a
Modify_Multimedia_Keys.desktop
file in the~/.config/autostart/
directory that contains the following content replacingYOUR_USERNAME
with your actual username:
[Desktop Entry]
Type=Application
Exec=/home/YOUR_USERNAME/.Modify_Multimedia_Keys.sh
Hidden=false
X-GNOME-Autostart-enabled=true
Name=Modify Multimedia Keys
Comment=This modifies keyboard multimedia keys
Best Answer
You can easily change the keyboard mapping on X Windows based systems with xmodmap. Install the xmodmap package
Look at the keyboard mapping for the keys of interest (pretty near the beginning for your keys0
Cut/paste the keys of interest into a file, called top-row-reset, (here's what mine look like):
This file may be used to reset any changes back to the default. Copy this file, and change the part to the right of the = sign to be what you want, either all your symbols or maybe reverse them e.g.:
or to reverse the shift make a file named mod-top-row
Run these files with the command xmodmap mod-top-row