I only uploaded this so that it may serve as inspiration. It is still being tweaked. The README may not completely match the implementation. It currently only supports Linux.
Touch typing on a standard keyboard could be better. Your thumbs idle while your weakest finger contorts to reach keys like Esc and BkSp. Numbers and other common symbols require you to abandon a comfortable hand position entirely. Exotic keyboards can remedy all this, but lack portability.
Handalf is a keyboard layout scheme that works well for fancy 40% keyboards with 2 or more thumb keys per hand, but it also fits broadly within the constraints of a laptop keyboard.
- Each finger travels one key at most. Your thumbs pick up the slack.
- Graceful degradation. You can keep a consistent layout, even when you're stuck on a laptop keyboard.
- Easy to learn & remember. The alpha keys won't change from whatever layout you already use, and all other symbols are accessible with the AltGr modifier on its own. There is a single additional layer beyond that, for navigation and function keys. Even then, there's no need to learn it all at once: I've found the symbols under AltGr to be the most ergonomically urgent.
- No homerow mods. While typing at speed, keypresses will often overlap, which means that any attempt at overloading alpha keys must resort to timeouts. This introduces visual delay and can cause misfires. You can train yourself and there are other ways to mitigate it, but I have not made such sacrifices here.
- Overloading is used sparingly, if at all. Even for non-alpha keys, overloading has the above downsides, albeit to a lesser degree. Therefore, only a single key can be judiciously given double duty: Esc. Even then, it is optional.
- Stateless. Modal editors are great, but only because they can provide continuous feedback about the current mode. Without looking at the keyboard, the only substrate upon which your brain can build associations is the physical position of your hands. Therefore, the key sent to your computer will depend only on the keys you are currently pressing, or at most which keys you were pressing some fraction of a second ago.
- Regressions are avoided. When stuffing so much functionality into a cramped space, it is inevitable that some key sequences will become harder to type. However, care has been taken to avoid making assumptions about the programs you will be running. That is, all modifier combinations should still be available, they should still stack in an intuitive and consistent way, and no reasonable shortcut should become impossible to type.
- Complete. A 42-key board should have access to all keys that you might find on a standard tenkeyless keyboard. This notably does not include a keypad or media keys.
Above all, the layout should feel good. Many concepts are taken into consideration, like simplicity, rolling motions, muscle memory, semantic clustering, symmetry, keeping actions and symbols separate, etcetera --- but the final decision is based on vibes. I know that a mapping is good when a handful of practice keystrokes will immediately render its absence on other keyboards painful.
Unfortunately, the layout is biased toward right-handed people.
If you are currently using Colemak, Workman or good old Qwerty/Azerty, then all alpha keys can stay in the same place. The major addition is that the Level-3 symbols on those keys (accessed through AltGr) have been crammed full with numbers and the other ASCII symbols for which you would normally have had contort your hands.
Note
The left-hand side of the keyboard now gives comfortable cross-hand access to common symbols like parentheses, while the number pad can be operated entirely with your right-hand.
The key to the left of Space, what would have been your Alt, is now the Fn key. Here, the navigation cluster is placed so that you can control the directional keys with only your left hand. The F-keys are on the right-hand side.
Note
Since the F-keys are not often used in modern applications, I use that half for navigating the window manager. Should the F-keys be needed in an application, the window manager enters a passthrough mode upon pressing Cancel.
In a multitude of operating systems and desktop environments, there exists a convention to assign global keybindings to the Meta key (also sometimes referred to as the Super, Windows, Command or GUI-key). Moreover, a tap on this key should bring up a global menu. This is achieved simply by pressing the remaining thumb key while in the Fn layer: Space.
BkSp takes the place of CapsLk, avoiding the huge move your pinky would have made.
Shift and AltGr are modifiers, but unlike Ctrl and Alt, they don't access shortcuts --- they simply provide more symbols. To make for a more comfortable typing experience, these keys are made sticky (or oneshot). Instead of holding and consciously releasing them just before pressing the next unmodified key, you can just tap once and forget about it. MUch better!
Double tapping Shift on its own gets you CapsLk and double tapping AltGr gets you NumLk.
The Multi key (also called Compose) allows you to type
special characters by typing intuitive keys in succession. For example,
Multic= becomes €. This key has been
placed at the position of ShiftL.
It is virtual, in the sense that there is no physical key that has this property by default. We assigned it to the '102nd key', that is, the \/| key that would exist to the right of ShiftL on ISO keyboards.
This is a natural choice, because (if your keyboard has this key) it is already in the right spot, and there are other ways to generate the symbols it is associated with.
You may have noticed that Shift is on your right-hand thumb, but on a laptop keyboard, that's just Space! In trying to compromise in as unobtrusive a way as possible, I have landed on the following:
Shift will also retain its function at the bottom of the outer edges of thae keyboard, but, when combined with AltGr or a preceding tap of Shift, it becomes a either a backslash \ or a Multi. If you keep holding it, the associated Shift modifier will also stay active.
Both of these keys are often followed by special characters, so you will usually need to activate the AltGr or Shift anyway. In this way, we retain an easily accessible Shift on generic keyboards, without wasting a good spot for a useful symbol key.
Optionally, you can keep shift functionality on only the left side, if that suits your typing style.
In general, it doesn't matter whether you press the right or left variant of a modifier, so the satisfying approach is to choose the left variant when the key occurs on the the left side (left Control and left Meta) and the right variant when the key occurs on the right side (right Shift). Left and Right Alt are a special case, because they often do perform distinguishable functions, and so we want to have access to both. We put them on the same side and refer to them by names that minimize their handedness: Alt and AltGr.
However, some tasks, like pulling up a menu or escaping a virtual machine, involve tapping a specific modifier on the right side. This is accommodated by the Fn layer, in which the rightmost keys are CtrlR and MetaR. Not coincidentally, since these are on the right hand, they also allow you to type otherwise inconvenient combinations in which your left thumb is already occupied, like Ctrl◀.
The Fn key occupies a very accessible location. Since it does not map to a conventional key anyway, you might be tempted, as I was, to give it double duty: emit another key when it is tapped in isolation. Particularly if you are a Vim user, Esc seems perfect for this. It is used frequently, and since it tends to punctuate a keystroke, the risk of accidentally triggering a Fn-hold is low.
Indeed, it is reasonable to take this approach. However, accidentally triggering Esc can be really annoying. Outside of Vim, it wreaks havoc by closing windows, cancelling spreadsheet formulas, and losing focus on input fields.
That is why I have chosen to overload it with Cancel instead --- a key that is barely used and not even present on contemporary keyboards. Specific programs must then be explicitly configured to interpret this key in a useful way.
If you now do get the itch to overload Esc for Vim purposes,
the effect will be contained to your terminal emulator.1 In foot, you
would put \x1b = Cancel in the [text-bindings] section, and in
Alacritty, you would put bindings = [{key = "Cancel", mods = "None", chars = "\u001b"}] in the [keyboard] section.
If you do not have the thumb keys to give Ctrl a good spot, you may want to consider the Pinky tweak.
While in the Fn layer, the a on your pinky would turn into an overloaded Ctrl/Esc. Try it --- it makes it very easy to type common shortcuts like Ctrlc and Ctrlf.
However, this tweak is optional, because hiding a modifier behind another key violates our design principles. Stack more modifiers on top, and you may need to pause your typing to think.
If you use both of the above tweaks, we get an overloaded Fn/Esc on your left thumb and a sticky Ctrl on your left pinky. Now you lose CtrlEsc, but this key was deliberately chosen to be useful yet expendable: it can still be produced in other ways.
Many computer users will have muscle memory associated with AltTab, so pressing Tab in the Fn layer will still emit exactly that. It will also keep the Alt modifier active until you either exit the Fn layer, or press another key in the Fn layer --- this is necessary to keep the overview of windows up.
When you press a key, your keyboard will send a scancode to the computer; the kernel maps that to a keycode; and finally, your keyboard layout considers that keycode (along with the active modifiers) and emits a keysym.
By default, Handalf remaps symbols at this keysym level, while other keys are mapped at the scan- or keycode-level. Teasing the two apart like this has several benefits:
- At the scan- and keycode-level, more tricks can be applied, like overloading.
- But at the keysym-level, your OS is aware of your active layout. You can switch between them in the standard way, with some visual indication.
- It becomes easier to reason about key composition. We don't have to explicitly write and remember rules for how layers and modifiers combine. Suppose, for example, you want to type Meta1: the first key would be ◐ and the second would be AltGrn.
- For layout-independent keybindings in your window manager, it is important that emitted keycodes stay the same even as symbols change.
Holding Shift and AltGr together does not change the keysyms, but it does change the keycode. This is helpful in applications that read keycodes rather than keysyms, or when you use a system in which the layout is not installed.
Install keyd (version >=2.3) and run
sudo make install. Activate the handalf layout in your environment.
Modifiers are keys like Shift, AltGr, Control, Alt, and Meta. These keys are sent along with the key you press to modify their behaviour. A layer key like Fn is similar, but it modifies the key directly.
You can rearrange the alphanumeric keys and action keys internally, and while some arrangements will be more comfortable than others, it will not lead to a fundamentally different typing experience. The same can not be said for modifier and layer keys. These keys can be overloaded, and it is to be expected that they are sometimes pressed in conjunction. I considered several permutations, landing on the following rules:
- The order in which you press modifiers and layers should not matter. That is, holding Fn and then Alt should have the same effect as the other way around.
- You should not have to press more than one key to activate a layer or modifier.
- All modifier and layer keys should be on the thumb.
- It should be assumed that the fingers are in the home row position; shifting your fingers a column or row is not always comfortable on sculpted keyboards like the Kinesis Advantage, MoErgo Glove80, Dactyl, or Keyboardio Model 100. (Dropping this requirement, along with the one preceding it, allows an interesting variant where the pinky activates a layer in which the arrow keys are on WASD. This works well on laptop keyboards, and frees up a thumb key for Ctrl.)
We can break these rules with explanation.
Actual numpad keys and media control keys have been left out of the layout. However, it would make sense to add them on an extra layer.
Footnotes
-
You could even directly configure (Neo)Vim itself to interpret your special key (see key-notation), but since most terminal emulators do not support wacky keys (cf.
terminfo), you would need to use another keystroke. ↩