9

My left pinky hurts due to repetitively pressing the C button when using Emacs org mode. Not working with Emacs is out of the question, but it needs some rest.

I would like to change theC key for something else for a while. Could I use, say, the ',' button instead?

  • 2
    In my case, the pain went away after I swapped my keyboard layout to use the caps lock key as the control key. You should be able to find a way to swap it here: https://www.emacswiki.org/emacs/MovingTheCtrlKey –  May 05 '18 at 13:23
  • @DoMiNeLa10: sounds like a good idea, at least it will change the point of pressure when I use the pinky. – j.j.johnson May 05 '18 at 13:29
  • I use a Kinesis Advantage keyboard which allows me to press the control and alt keys with my thumbs and this helps a lot. The disadvantage is that they are quite expensive. – Qudit May 05 '18 at 14:14
  • 2
    The problem with this type of question is that it invites a discussion regarding remapping keys at the system level v. in Emacs, different keyboards and foot petals, ergonomics / posture of the user while sitting at the computer, various computer programs for different operating systems that remap keyboard shortcuts, etc. In general, these types of questions come up on Reddit with Emacs tag about once every week and there are about a zillion people who all chime in with their personal opinions. I am voting to close this question as it is overly-broad and seeks an opinion versus a solution. – lawlist May 05 '18 at 15:12
  • 1
    Please clarify if your question is "what to do about Emacs pinky" or "how do I make some other key behave as the Control modifier". – Dan May 05 '18 at 16:16
  • I'm voting to close this question as off-topic because it's OS-dependent rather than Emacs-related. – Stefan May 08 '18 at 02:02
  • To the downvoters, the solution is OS or hardware dependent but the problem is one that is unique to emacs. – user2699 May 08 '18 at 02:17
  • The problem is not necessarily unique to Emacs, actually. Just because you don't use other applications that make heavy use of the Ctrl key doesn't mean that they don't exist. However, the fact that you're looking for a solution in Emacs makes the question on-topic. I'm puzzled by the close votes here. “Could I use, say, the ',' button instead?” is on-topic here. – Gilles 'SO- stop being evil' May 08 '18 at 10:26
  • The problem is not unique to Emacs, but it is far more common among Emacs users for obvious reasons. – Qudit May 08 '18 at 18:15

7 Answers7

8

Emacs pinky is a common issue, there are severals way to deal with it:

  1. swap Control key to something else (usually Caps Lock).
  2. Use your palm instead of pinky to press Control key.
  3. Use an ergonomic keyboard.

You can check emacs wiki to see how other users do. https://www.emacswiki.org/emacs/RepeatedStrainInjury

Rangi Lin
  • 987
  • 9
  • 15
  • Upvoting solely for suggestion (2) (although I've tried swapping control, using the side of the hand feels more natural and works with any keyboard. See some more discussion at http://ergoemacs.org/emacs/emacs_pinky.html – user2699 May 08 '18 at 02:19
4

You can define a key that applies a modifier to the next key in Emacs.

(define-key function-key-map "," 'event-apply-control-modifier)
(global-unset-key ",")
(defun insert-comma (count)
  (interactive "*p")
  (insert-char ?, count))
(global-set-key [(control ?,)] 'insert-comma)
(global-unset-key "\e,")
(global-set-key [(control meta ?,)] 'tags-loop-continue)

Then pressing , then a is equivalent to pressing Ctrl+a. Press , twice to insert a comma.

There are limitations. Ctrl+Shift bindings work if you press , then Shift+key, but for meta you can't press Esc then , then key. If a mode defines its own binding for , or Ctrl+, or Meta+, then it will override the comma-as-a-modifier bindings. Inserting a comma is no longer a self-insert, which has a few consequences (the same as making a character electric) such as breaking undo sequences, not necessarily doing what you'd expect from a self-insert to the selection, etc.

I don't think there's a way to apply this to a specific mode. You can apply it to a specific terminal (but not to a specific window on a GUI) with local-function-key-map but I don't know if that would help you.

See also the Emacs wiki page on sticky modifiers. That doesn't do exactly what you're asking, but one of the features on this page may be an acceptable solution for you.

  • Thanks for the tip! I've put it into my .emacs file, and it works fine for commands of the form C-letter and C-x letter, but if I try to use it for C-x C-letter, it says "fill-prefix" and then something, and throws me out of C-x mode (sorry about the bad nomenclature, I'm still a noob). Is there a way so that I can use it for commands of the form C-x C-letter? – Alexander Praehauser Jan 22 '23 at 09:13
  • Also, that still doesn't help for using C-f and such to move within a document. Is there a way I can tell it to use the "," key just as "Crtl" if I keep it pressed, and use it to apply "Crtl" to the next key if I just push it quickly? – Alexander Praehauser Jan 22 '23 at 09:22
  • 1
    @AlexanderPraehauser No, Emacs only exposes key press events (one when you initially press the key, and if you hold it down then repeats at the discretion of the operating system), not down/up events. If you want fancier control, you need to make the operating system do it. – Gilles 'SO- stop being evil' Jan 22 '23 at 11:02
1

After using emacs for almost 10 years, I think the best way to avoid emacs pinky is to remember:

Bind the keys such that you never press two or more keys at the same time with one hand!

This completely eliminates any hand problems I used to have.

For example, C-x should always be pressed like this: C (right hand) - x(left hand)

Using space or caplock to replace control will delay but not completely prevent your hand problems. The only way to prevent them is to never press two keys at the same time with one hand.

DataHungry
  • 247
  • 1
  • 7
  • 1
    Furthermore, consider (seriously) using sticky modifier keys, such that you don't need to hold a modifier key down while pressing another key. I thought I would hate it, and that it would take me ages to get accustomed to, but I was genuinely astonished by how rapidly I adapted to it. I wish I'd done it many years earlier. – phils Oct 23 '19 at 05:04
0

Use the CTRL Key! My professor showed me this in college and I have been using this kbd mapping ever since on any system I use.

  • MacOS - built in kbd mapping
  • Linux - setxkbmap, or on Ubuntu systems modify /etc/default/keyboard and add "ctrl:nocaps" to keyboard options. (XKBOPTIONS="ctrl:nocaps") or (XKBOPTIONS="ctrl:swapcaps") to swap caps and ctrl. The former will give you ctrl as ctrl and caps as ctrl. This is better than tweak tool because you'll get caps as ctrl in tty's as well.
  • Windows - Sharpkeys

Excellent Link: EmacsWiki: Moving the CTRL Key

r3dfarce
  • 11
  • 3
0

I just realized that I have used the Ring Finger to press the Ctrl key and that has worked all these years of emacs experience. Hopefully that could mean a new beginning for you.

aartist
  • 133
  • 5
0

This problem is actually solved in year 2012 when EVIL is mature.

Simple solution,

Please use Spacemacs+Evil. Vim key bindings make sure you type less keys when dealing with text. Use space as leader key so you don't need move finger from its default position too frequently.

In other words, if you don't use key like Ctrl/Alt/Shift/Win/Cmd/Esc, you solve the problem from root cause.

Advanced solution,

Please use Evil. Then measure your frequency of key pressing by using package keyfreq.

See http://blog.binchen.org/posts/how-to-be-extremely-efficient-in-emacs.html for tech details.

If you want to start optimization immediately without using keyfreq, here is my one year data you can use,

https://gist.github.com/redguardtoo/99e69fe3ecfccadeacdb6f1c40978b0c

This solution works on any environment. It also immediately speedup you productivity so you can code much faster. In summary, there is NO side effect at all.

BTW, at the beginning, you only need optimize top 20 commands.

   6008   13.33%  evilmi-jump-items                    %, <visual-state> %, <normal-state> %
   4292    9.53%  winum-select-window-2                , 2, M-2
   3806    8.45%  winum-select-window-1                , 1, M-1
   2522    5.60%  switch-to-shell-or-ansi-term         , x z, C-x C-z
   2280    5.06%  my-counsel-recentf                   , r r
   1910    4.24%  my-multi-purpose-grep                , q q
   1791    3.98%  back-to-previous-buffer              , b b
   1561    3.46%  winum-select-window-3                , 3, M-3
   1379    3.06%  counsel-etags-find-tag-at-point      C-]
   1222    2.71%  eval-expression                      , e e, M-:, M-ESC :
   1153    2.56%  evil-visualstar/begin-search-forward <visual-state> *
    971    2.16%  my-evil-goto-definition              g t
    793    1.76%  copy-to-x-clipboard                  , a a
    654    1.45%  pop-tag-mark                         C-t
    633    1.40%  counsel-imenu                        , i i
    616    1.37%  paste-from-x-clipboard               , z z
    539    1.20%  winum-select-window-4                , 4, M-4
    522    1.16%  toggle-full-window                   , f f
    420    0.93%  evil-toggle-input-method             C-\
    371    0.82%  git-add-current-file                 , v a
    322    0.71%  evilnc-comment-or-uncomment-lines    , c i, M-;
    302    0.67%  backward-delete-char-untabify        
    295    0.65%  my-split-window-vertically           , x 2, C-x 2
    285    0.63%  find-file-in-project-by-selected     , k k
    279    0.62%  delete-other-windows                 , x 1, , s 1, C-w C-o, C-w o, C-x 1, <menu-bar> <file> <one-window>
    278    0.62%  langtool-goto-next-error             , l l
    273    0.61%  find-function                        , h f, C-h C-f, <f1> C-f, <help> C-f
    270    0.60%  kill-buffer                          , x k, C-x k
    261    0.58%  my-split-window-horizontally         , x 3, C-x 3
    251    0.56%  narrow-or-widen-dwim                 , w w
    235    0.52%  counsel-find-file                    , x f
    224    0.50%  winner-undo                          , u u, C-c <left>, C-x 4 u
    203    0.45%  beginning-of-defun                   , b f, <C-M-home>, C-M-a, ESC <C-home>
    202    0.45%  c-electric-backspace                 
    201    0.45%  evil-a-paren                         
    190    0.42%  counsel-describe-variable            C-h v, <f1> v, <help> v
    187    0.42%  org-shifttab                         
    187    0.42%  wg-create-workgroup                  SPC s s
    186    0.41%  evil-surround-region                 <visual-state> S
    155    0.34%  ffip-diff-find-file                  
    154    0.34%  flyspell-goto-next-error             , f e
    153    0.34%  counsel-etags-find-tag               , f t
    152    0.34%  ivy-switch-buffer-by-pinyin          , x b
chen bin
  • 4,857
  • 20
  • 36
0

Left alt (i.e., meta key in Emacs config) key can be pressed easily using your left thumb, and you can rebind all of your common functions (e.g., cursor movements) to meta-key-based shortcuts instead of the original ctrl-key-based shortcuts. I do that in my init.el file.

AhLeung
  • 1,083
  • 5
  • 14