Monday, 5 September 2022

Swap Escape and Tilde (backtick) keys on Ubuntu

Use a 60% keyboard and want to map Caps lock to Escape and Escape to backtick (`) & tilde (~)?

Assuming you use the English (US) keymap, modify the following file (on Ubuntu 20.04)

/usr/share/X11/xkb/symbols/us

This is the diff: (us.bak is the original unmodified version of us)

diff --git a/us.bak b/us
index 798926f..efb81a2 100644
--- a/us.bak
+++ b/us
@@ -3,7 +3,8 @@ xkb_symbols "basic" {
 
     name[Group1]= "English (US)";
 
-    key <TLDE> {	[     grave,	asciitilde	]	};
+    key <ESC>  {	[	grave,	asciitilde	]	};
+    key <CAPS> {	[	Escape, Escape		]	};
     key <AE01> {	[	  1,	exclam 		]	};
     key <AE02> {	[	  2,	at		]	};
     key <AE03> {	[	  3,	numbersign	]	};