How to remap keys in Ubuntu 18.04 (GNOME Shell)

11,480

Using xkb worked.

Edit this file: /usr/share/X11/xkb/symbols/pc. Don't forget to use sudo with something like sudo -i gedit /usr/share/X11/xkb/symbols/pc

It'll be fairly straight forward what's going on in there. Key is defined on the left, and effect is defined on the right. Maintain the indentation and all that.

Should work for any kind of remapping.

You'll need to log out and back in (or use the following commands) for changes to take effect:

setxkbmap fr # if you are using french azerty layout
setxkbmap us # if you are using US qwerty layout
... And so on
Share:
11,480

Related videos on Youtube

Josh
Author by

Josh

Learned how to code when I tried to start an online business after college. The business failed basically instantaneously, but I found a love for code that's lasted and come to impact the way I think about entrepreneurship and many other things in life. More about me here: general bio I was in the 2014 summer batch at Hacker School, now The Recurse Center, which was incredible! I had never met any other developers before, I didn't know how to pronounce gif (I still don't)... not to mention, it's an incredible community for developers. These days I work mostly with scientists, NASA, the National Science Foundation, etc, by designing and facilitating 5-day innovative research conferences. Tons of fun : ) Check out Knowinnovation for more. Looking forward to Q&A'ing with everyone here.

Updated on September 18, 2022

Comments

  • Josh
    Josh almost 2 years

    Trying to swap PgUp and PgDn to Home and End.

    xmodmap doesn't seem to work for anything other than xev output. Doesn't work in other cases.

  • Yasser Hussain
    Yasser Hussain almost 5 years
    Doesn't work. I tried remapping ALT key to L_CTRL.
  • Alex Barchiesi
    Alex Barchiesi over 4 years
    CTRL_L -> ATL_L does not work for me. After some test I think this could be related to my keyboard: a mac keyboard (It's ubuntu on an old mac book air laptop) because it works with an external one.
  • ironchicken
    ironchicken over 4 years
    Used this answer to map PgUp to Left and PgDn to Right on my Dell XPS which has tiny Left and Right keys with tiny PgUp and PgDn keys far too close together!