Is it possible to remap the CapsLock key system wide such that when the CapsLock button is pressed by itself it acts as the escape key and when pressed with another key it acts as the control key?
Remap CapsLock to Escape and Control – System Wide Guide
keyboard
Best Answer
I have found a very good solution called xcape. From the README: