Skip to content

Comment on A Modern Space Cadetparent

Comments

I played around with implementing something like this on linux (with xmodmap specifically) and didn't find anything conditional. I did figure out how to make holding right shift and tapping left produce a left parenthesis, and vice versa produce a right.

This is from memory, so bear with me if its not perfect, but I setup xmodmap with

keysym 50 = Shift_L parenleft Shift_L keysym 62 = Shift_R parenright Shift_R

Xmodmap allows you to define multiple symbols for a key. The first symbol is what you get with no modifiers; the second is with shift; the third is with Mode_switch (or AltGr, depending) and the fourth is with Shift and AltGr. There's sometimes although a 5-8, but that varies by platform and I haven't done enough experiments to really nail down what those are for linux these days, OR if those are tied to mod1/mod2/etc. instead of shift/altgr/mode_switch or specific modifiers like that.

Anyway, all the keysyms always defined the first three anyway (no modifiers, shift, and Mode_switch) and some defined the fourth. I don't have or use a Mode_switch key (yet) but I may try that out as a 'Greek' key or such, but since 90% of the time I'm programming I'm not sure if I'd ever use it.

My lines above defines parenleft as the symbol to send if key 50 (the left shift key) is pressed while the shift modifier is active. So, I can use the right shift to turn on the shift modifier, and then left shift turns into a left parenthesis key. Similarily, I can use the left shift key to turn the right shift into a right parenthesis.

So, to type a pair of parenthesis back to back "()" I press right shift, press left shift, release right shift, and tap right shift. It's certainly more awkward than what Steve was able to setup, but hey, its where I've got so far.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.