Have you tried keyremap4macbook ?
By checking the option:
Change Command_R Key (Right Command) > Command_R to Escape
I am using the right command as meta/alt key throughout mac os.
Wow! User teika kazura's comment on the original question is quite correct — not only is this effectively a duplicate of that other question, but the answer provided there ("use xcape") solves this problem!
After cloning the xcape repo and compiling (I had to install libXtst-devel on my Fedora box, first), I was able to obtain the exact behavior requested with the following command:
xcape -e "Shift_L=parenleft;Shift_R=parenright"
After admittedly-cursory testing, it seems to work extremely well. Nice!
Other Options
If you use the Shift key as a mouse modifier (i.e. if you ever shift-click anything), you'll probably want to include xcape's timeout option and find a comfortable timeout value, so that solo Shift keypresses used in combination with the mouse don't generate spurious parentheses. From the xcape README:
-t <timeout ms>
If you hold a key longer than this timeout, xcape will not generate a key event. Default is 500 ms.
So, by including the -t
flag with a timeout value that works for you, you'll still be able to shift-click with the mouse as long as you hold down Shift for at least timeout ms
milliseconds.
(Credit, again, to teika kazura for pointing out the other question, and also to don_crissti for the original answer there.)
Best Answer
The answer was as easy as this: