Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
FYI: Escape the backtick and other special characters like this: \` –  djeikyb Apr 4 '11 at 9:07

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
if you s/escape/Escape then this is all good. –  oadams May 10 '12 at 5:20

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.