]> oss.titaniummirror.com Git - oss-web.git/blob - in/blog/swapkeys.md
Blog entry keyboard-specific-mappings.md
[oss-web.git] / in / blog / swapkeys.md
1 title: Swapping Control and Super Keys
2 linktitle: swapkeys
3 parent: 2014-03
4 ctime: 2014-03-22
5 mtime: 2014-03-22
6
7 After marathon multi-hour code sessions, I will sometimes get wrist discomfort.
8 I've learned that one of the key actions that trigger discomfort is [ulnar
9 deviation]
10 (http://www.exrx.net/WeightExercises/WristFlexors/DBUlnarFlexion.html). I've
11 noticed that rotating my wrist in this fashion to reach the control keys with
12 the pinkies repeatedly can really get my wrists fired up. Since I tend to live
13 in the vim text editor, I tend to use this motion frequently!
14
15 To reach the control keys on most keyboards, one needs to move the entire arm
16 and/or "ulnar deviate". But if the control keys are in the right position, one
17 can use the "partial fist" method to depress them -- that is, roll up the pinky
18 as if making a fist, and depress the key on the row with the space bar using
19 the pinky's knuckle. This movement is accomplished with no arm movement and no
20 ulnar deviation.
21
22 The problem with this partial fist method is that on most keyboards, one ends
23 up hitting the windows key (on the left) and the menu key (on the right), and
24 not the control keys. In Linux, these keys are referred to as the Super keys.
25 So my solution to help alleviate some wrist pain is to re-map the keyboard to
26 swap the Super and Control keys. I even pulled the keycaps off and moved them,
27 for completeness (ensure your keyboard has removeable keycaps before trying
28 this).
29
30 There are several ways to do this remapping, but the method I like the best is
31 to change the keycodes assigned to the keys. The other method is to change
32 the actions assigned to the keycodes, but I had various problems with this
33 approach. Two simple script files, `swapctrl` and `unswapctrl` do the job.
34
35
36 #!/bin/bash
37 # Script to swap Control and Windows keys by reassinging keycodes
38
39 xmodmap -e "clear Control"
40 xmodmap -e "clear Mod4"
41 xmodmap -e "keycode 133 = Control_L NoSymbol Control_L"
42 xmodmap -e "keycode 37 = Super_L NoSymbol Super_L"
43 xmodmap -e "keycode 134 = Control_R NoSymbol Control_R"
44 xmodmap -e "keycode 105 = Super_R NoSymbol Super_R"
45 xmodmap -e "keycode 206 ="
46 xmodmap -e "add Control = Control_L Control_R"
47 xmodmap -e "add Mod4 = Super_L Super_R"
48
49 and
50
51
52 #!/bin/bash
53 # Script to unswap Control and Windows keys by reassinging keycodes
54
55 xmodmap -e "clear Control"
56 xmodmap -e "clear Mod4"
57 xmodmap -e "keycode 37 = Control_L NoSymbol Control_L"
58 xmodmap -e "keycode 133 = Super_L NoSymbol Super_L"
59 xmodmap -e "keycode 206 = NoSymbol Super_L NoSymbol Super_L"
60 xmodmap -e "keycode 105 = Control_R NoSymbol Control_R"
61 xmodmap -e "keycode 134 = Super_R NoSymbol Super_R"
62 xmodmap -e "add Control = Control_L Control_R"
63 xmodmap -e "add Mod4 = Super_L Super_R"
64