How to disable specific combinations of keystrokes

keyboard shortcutskeyboard-layoutx11

I've been suffering from RSI recently and am trying to make an effort to be more disciplined about typing. One of the things I've noticed is that I sometimes (out of habit) use combinations of keys that force me to stretch.

For example, to type an open-paren ( I often hold down right-shift and use my right hand to press the 9 key. This involves twisting my wrist uncomfortably. I would like to train myself to hold down the left shift key instead but it's hard to get out of the habit.

Is there an application that will allow me to either (1) disable the combination of right-shift + 9 or (2) pop up a reminder when I hit that particular combination? I guess it would have to be something that works across applications.

Best Answer

I figured out that xmodmap was the correct solution here. In the .Xmodmap file, turn off shift, then add right shift as mode switch and add left shift as shift:

clear Shift
keysym Shift_R = Mode_switch
add Shift = Shift_L

Now the order of the first few keysym columns is key, left_shift+key, right_shift+key. So for my parentheses example:

keycode  18 = 9 parenleft 9 parenleft bracketright plusminus bracketright

Because right shift now is no longer recognized as shift, it will stop working for all keys until you put it back in the third column e.g. I want a to work with right shift but not left shift:

keycode  38 = a a A A ae AE ae

Hint: if you mess things up while playing about with xmodmap, run

setxkbmap

to return everything to a default state.

Related Question