Swapping Numbers and Symbols on the Keyboard

Something you may have found especially if you are a programmer is that the numbers and symbols at the top of the keyboard would be much better the other way round. There is actually an easy way to swap the numbers and symbols so that if you press for example the 5 key you will get % and if you hold shift and press the key you get the number 5.

There is two things about what is written below that you should know, one is that this is for Linux and while it is likely also possible on windows or mac you will need to find the method yourself. The other thing is that this will affect your keyboard shortcuts, this means that if you have a keyboard shortcut that uses a number key you will have to either hold shift or change the shortcut.

I also recommend that you have some command line knowledge if you are going to attempt this. There is also a chance you could make changes that prevent your keyboard from working correctly, if this happens delete the .Xmodmap file that you create in the instructions bellow and restart the xorg server (you can do this by restarting the computer)

Before you start you will need some software xmodmap which we will be using to make the modifications to our keyboard layout.

Once installed you need to create a file called .Xmodmap in your home directory with your current layout to do this use the command

xmodmap -pke  ~/.Xmodmap

Now open the file you just created, it will be hidden so you will need to enable display hidden files in your file manager or you could open it via the command line using your favourite text editor.

What you are looking for is something like what is shown below, it may be near the top of the file and the keycodes may be different depending on your keyboard settings

(displayed for numbers 1-3)

keycode 10 = 1 exclam 1 exclam
keycode 11 = 2 at 2 at
keycode 12 = 3 numbersign 3 numbersign

What you now need to do is for numbers 1-0 change them to match what is shown below (ignore the keycodes as they may be different)


All that needs to be done is to move the digit from the front of the line after the “=” to the back of the line

Now to test the changes use the command

xmodmap ~/.Xmodmap

You should now have a keyboard with it’s numbers and symbols swapped.

If you use startx to start your xorg server then you need to add this to your .xinitrc file located in your home directory (it is a hidden file). This will allow the changes to be loaded every time the xorg server is started.

if [ -s ~/.Xmodmap ]; then
xmodmap ~/.Xmodmap

This is only a small amount of what can be done using xmodmap and while it’s capabilities are limited compared to some of the other options out there for modifying keyboard layouts there is a lot you can do to configure your keyboard layout, all it may take is a quick Google search. This may only be the beginning of your keyboard customising efforts (much to the dread of anyone else that uses your computer).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s