A Typist’s Keymap

John Steinberger
8 min readAug 2, 2020

--

This post describes a modification of the ordinary keyboard layout (a.k.a., a “keymap”) that I’ve used to type and edit text quickly.

Usage details for mac are included at the end of the post.

1. Spacebar becomes Shift

Spacebar is mapped to Shift if pressed in conjunction with something else. The spacebar alone produces a space, as usual.

2. Semicolon (the key under the right-hand pinky) becomes Return

(We’ll remap the colon and semicolon to somewhere else, see below.)

3. The left and right shift keys become Control

Now that we have the spacebar for shift, we might as well reassign the shift keys to something else.

4. Caps Lock to Escape

When pressed alone, Caps Lock becomes Escape.

5. Caps Lock + JKL; to left/right/up/down

Have the arrow keys under the home row of the right hand.

There is a small twist: I actually have Caps Lock + JK mapped to Option+Left Arrow, Option+Right Arrow, respectively. Because one more often wants to move left/right by a whole word than by a single character.

On the other hand I’ve mapped Caps Lock + M, (right beneath JK: ‘M’ and ‘,’) to the ordinary left/right arrows.

Note that if you simultaneously press the spacebar these commands will extend the current selection, as the cursor moves around. (Since the spacebar acts as the shift key, when pressed in conjunction with anything else.)

6. Weird exceptions: Spacebar + J and Spacebar + K map to back and forward delete, respectively

Spacebar+J and Spacebar+K are essentially the two most ergonomic key combinations on the keyboard. Normally these combinations would give us an uppercase ‘j’ and ‘k’, respectively, but I’ve mapped Spacebar+J to backspace and Spacebar+K to “forward delete”.

Deletion is the unseen-but-ubiquitous editing operation. Close to 100% of all keystrokes can be headed for deletion, one way or the other. The importance of having good deletion shortcut(s) is too often overlooked.

My workaround to get the actual uppercase ‘J’ and ‘K’ is Right Command + J/K.

7. Delete chunks of text by selecting, then typing Spacebar + J

Use the select-and-delete paradigm for deleting a word or a larger chunk of text at a time. This means that you don’t have to memorize special-purpose combinations for long-range deletion. It also means that you get to see what you’re deleting as a selection before finalizing the deletion. By the same token you can change your mind at the last minute and cut the text (Command + X on mac) instead of deleting it. Yet another thing you can do is to type over your selection without even pausing to press “delete”.

8. Left Option alone to Command + F

We often want to search through text. When pressed alone, the Left Option key triggers the Find command. Moreover, code editors can be programmed to map “Find” to “Find Next” when the Find dialog is already open, meaning that Left Option operates both as “Find” and “Find Next”: no use really for two separate commands.

9. Caps Lock + Right Command + JK for goto-beginning-of-line, goto-end-of-line

The standard shortcuts for goto-beginning-of-line, goto-end-of-line are Ctrl+A, Ctrl+E on linux. Once CapsLock+JK has been internalized as meaning “go left”, “go right”, adding a modifier key (in this case Right Command) to these combinations in order to achieve “end of line” versions make more sense for the brain.

Note that simultaneously pressing the spacebar will select from the current caret position to beginning- or end-of-line (because spacebar is Shift). The spacebar is always pressed with the left thumb, for simplicity, meaning that the left thumb has to be kept free for all motion-related shortcuts (and is this why this shortcut uses the right command key as the modifier, not the left command key).

10. Left Shift + JKL; to -+*/

Put the arithmetic operators under the home row, with Left Shift (that is internally mapped to Left Control, as described above) as the modifier key to access them.

Moreover, if the spacebar is also pressed, then we produce the “spaced” version of these operators. (E.g., LeftShift+Spacebar+J produces the sequence “⊔−⊔” where “⊔” denotes a space, LeftShift+Spacebar+K produces “⊔+⊔”, and so on.)

11. Swap Line Up, Swap Line Down, Select Next Line Up, Select Next Line Down, Duplicate Line, Delete Line, Comment Line, Duplicate-and-Comment Line with Left Option + M, /L;JK.

  • Swap the current line upwards (i.e., swap with previous line) with Left Option+L
  • Swap the current line downward with Left Option + ;
  • Extend current selection by one line upward with Left Option + J
  • Extend current selection by one line downward with Left Option + K
  • Retract current selection by one line from top with Left Option + Spacebar + J
  • Retract current selection by one line from bottom with Left Option + Spacebar + K
  • Duplicate the current line with Left Option + M
  • Delete the current line with Left Option + ,
  • Comment out the current line with Left Option + /
  • Duplicate-the-current-line-and-comment-out-the-old-copy with Left Option + .

Note that “Extend the current selection by one line downward” also acts as “Select the current line”, if the selection is currently empty. On the other hand, “Extend the current selection by one line upward” acts the same as “Select the current line, and one line before that” if the current selection is empty, in order to avoid redundancy.

12. Goto-end-of-line-and-return, goto-end-of-line-and-colon-and-return, goto-end-of-line-and-period-and-return, goto-end-of-line-and-comma-and-return, goto-end-of-line-and-semicolon-and-return with…

First off: I forgot to say that / (typed on its own) and Left Shift+/ are the new key combinations for colon and semicolon, respectively. (Indeed, the old colon/semicolon key has been mapped to Return.)

Now:

  • goto-end-of-line-and-return with Spacebar + ; (aka “spacebar + return”)
  • goto-end-of-line-and-insert-comma-and-return with Spacebar + ,
  • goto-end-of-line-and-insert-period-and-return with Spacebar + .
  • goto-end-of-line-and-insert-colon-and-return with Spacebar + / (aka “spacebar + colon”)
  • goto-end-of-line-and-insert-semicolon-and-return with Spacebar + Left Shift + / (aka “spacebar + semicolon”)

(Nb: A semicolon feels more “emphatic” to me than a colon, so I decided to make typing the semicolon require a modifier key, whereas the colon not. The colon also seems to be more prominently used in most modern programming languages.)

13. Right Command + Caps Lock to ‘Undo’

This is slightly more ergonomic than the standard Command + Z.

Add the spacebar for ‘Redo’.

14. Left Shift (alone) to “Select Word Under and/or Find Previous Occurrence Of”

In code editors, find the last previous occurrence of the currently selected word by pressing Left Shift. If no word is yet selected, the editor selects the word that is currently nearest to the caret.

15. Right Shift (alone) to “Select Word Under and/or Find Next Occurrence Of”

(Symmetric.)

16. Right Command + Left Shift to “Add previous occurrence of currently selected word to current selection”

If you’ve previously worked with a multi-selection editor you know what this means, otherwise it’s pointless for me to try to explain.

17. Left Command + Right Shift to “Add next occurrence of currently selected word to current selection”

(Symmetric.)

18. A few one-off characters

Some more convenience characters — don’t try to learn these all at once, or you will damage your brain (and your long-term ability to memorize them, too):

  • Left Shift + O produces “=”
  • Left Shift + Spacebar + I produces “?”
  • Left Shift + Spacebar + O produces “⊔=⊔”
  • Left Shift + , produces “<”
  • Left Shift + . produces “>”
  • Left Shift + Spacebar + , produces “⊔<⊔”
  • Left Shift + Spacebar + . produces “⊔>⊔”

(Recall that Spacebar + , and Spacebar + . produce goto-end-of-line-and-insert-…-and-return commands, whence the necessity of some other keyboard shortcuts to access “<” and “>”.)

  • Caps Lock + / produces “:⊔”
  • Caps Lock + I produces “^” [caret]
  • Caps Lock + O produces “_” [underscore]
  • Caps Lock + Spacebar + I produces “\”
  • Caps Lock + Spacebar + O produces “$”

The last five combinations can be particularly important for LaTeX users.

19. Left Command + JK to switch applications

Left Command + J and Left Command + K to switch left / right through the list of open applications. (I.e., what Command + Tab and Command + Shift + Tab does on mac.)

20. Left or Right Command + M, to switch tabs

Command+M for “previous tab” and Command+, for “next tab”.

21. Left or Right Command + ./ to switch windows

Command+. for “previous window” and Command+/ for “next window”.

22. Delimiters #1: Right Option alone to ()

To open a pair of parentheses with the caret centered inside press the Right Option key on its own. The keymapper detects if you’re using a code editor, in which case it reverts to inserting “(” and gets out of the editor’s way (that will have its own well-thought-out default behavior).

23. Delimiters #2, 3: Right Command alone to {}, Left Command alone to []

(…)

24. Delimiters #10: Left Command + Right Command to \{\}

For LaTeX people: Press Right Command + Left Command to insert the sequence “\{\}” with the caret backtracked to the middle point.

25. Etc.

See the Karabiner-Elements .json file below for more details and ideas. Invent your own! Note that some things (such as 14, 15, 16, 17, e.g.) require further tweaking with the code editor of your choice, and cannot be carried out by the keymapper alone.

26. Do-It-Yourself

For Mac users:

  1. Download and install Karabiner Elements:

3. Startup Karabiner Elements and poke around.

If ~/.config/karabiner/karabiner.json does not yet exist on your machine (that’s a hidden folder named “.config” in your home directory; if you don’t know how to use the Terminal app to navigate your filesystem, note that Command + Shift + . toggles the visibility of hidden files and folders in Finder), then follow the ‘Export’ instructions here:

4. Replace the contents of the ~/.config/karabiner/karabiner.json file with this paste, and select the profile named “Karmchenki”: https://pastebin.com/LJHedMgQ.

You are done.

For future debugging purposes, you might also want to download and install Karabiner-EventViewer, a separate app that logs the final keyboard signals received by the machine after Karabiner-Elements has done its mapping.

--

--