Ubuntu – How to swap the Z and Y keys on the keyboard

keyboard-layout

Most of the time I use the US qwerty layout but from time to time I also have to use the German layout which is qwertz and it is very annoying.

How can I swap the y and z keys on the German layout?


The solution was at this link:
Custom Keyboard Layout in Ubuntu (or just Linux 🙂 kindly provided by gertvdijk in his answer.

NB: In recent versions of Ubuntu you have to issue sudo dpkg-reconfigure xkb-data for the changes to take effect. See this answer.

Best Answer

This how-to should do the trick for system-wide keyboard remap of single keys: FAQ: How to disable/remap a keyboard key in Linux?

And this how-to is about creating your own custom keymaps: Custom Keyboard Layout in Ubuntu (or just Linux :)

It won't allow you to change it quicky using a shortcut. You'll need some scripting to do so, I guess.


However, from the first revision of your question I assumed you wanted to change layouts. You've revised your question, but here is how to change layouts:

From the tags I assume you're running Kubuntu (KDE) 12.04 changing layouts pretty straightforward:

  1. Open 'System Settings'
  2. Open 'Input Devices'
  3. Select 'Keyboard' on the left vertical tab.
  4. Select 'Layouts' on the horizontal tab.
  5. Tick the checkbox 'Configure layouts'.
  6. Add your preferred keyboard layouts by clickin the 'Add' button and filling in the fields in the dialog. Selecting an English (US) layout will result in 'qwerty'. -- Optionally configure a shortcut key to change layouts quickly.
  7. Click apply.

KDE keyboard configuration dialog

This should cover keyboard layout and behaviour in your user session. For system wide settings including text console, see this question.