Simplest way to swap esc key with ` key

7,533

Solution 1

You want to follow the five-point list of instructions on the ubuntuforums by Andy Meier: http://ubuntuforums.org/showthread.php?p=10286878#post10286878

The keys you'd have to modify in your /usr/share/X11/xkb/symbols/mynewlayout would be:

key <ESC> {[ quoteleft, asciitilde ] };

key <TLDE> {[ escape ] };

You then have to register this new layout as described on the forum. Good luck.

Solution 2

Xmodmap replaces keycodes. shift+esc is not a different key. Check the output of xev when you press a and shift+a. You'll find the state changes from 0x0 to 0x1 while the keycode stays the same. What you want to do is change the definition of a key, not just tack on the A/a or ~/` keys. Redefining the output of key's state change is outside the scope of xmodmap.

I don't know exactly how to do what you want, but I think creating a keyboard definition is the right way. I'll edit with more help if or when I figure out how to do this. Maybe this will set you on the right path.

Solution 3

I read elsewhere that Ubuntu is no longer using xmodmap. It's using xkb instead. There's some info on that in this post:

Permanent xmodmap in Ubuntu 13.04

However, I'm still using 12.04LTS, and I wanted to swap my Esc and grave keys. I did it with xmodmap and it worked.

I created a small script that runs xmodmap and I have that script run when I login. The xmodmap commands are:

xmodmap -e "keycode 49 = Escape"
xmodmap -e "keycode 9 = grave asciitilde"

I don't know if this solution will work in versions of Ubuntu newer than 12.04.

Share:
7,533

Related videos on Youtube

oadams
Author by

oadams

Updated on September 18, 2022

Comments

  • oadams
    oadams over 1 year

    What is the simplest way to swap the functionality of the Esc key and the ` key?
    System ➜ Preferences ➜Keyboard ➜ Layouts ➜ Options let me swap my Ctrl key and Capslock key, which was good, but it doesn't seem to let me do other keys in a generalized way.

    The xmodmap answer that got accepted here was useful. Now my ` key is on the physical Esc key, and vice versa. The problem is that when I Shift+Esc I still only get a ` when I'd like to get a tilde.

    • djeikyb
      djeikyb about 13 years
      FYI: Escape the backtick and other special characters like this: \`
  • oadams
    oadams almost 12 years
    if you s/escape/Escape then this is all good.
  • markwatson
    markwatson over 8 years
    Yep, needs s/escape/Escape for me on Fedora 23. Can the answer be edited?