I am mostly happy with the layout. There may still be some minor changes in the implementations as edge cases are being ironed out. The README may not yet completely match the implementations.
Touch typing on a standard keyboard is not a great experience. Your thumbs idle while your weakest finger contorts to reach keys like Esc and BkSp. Numbers and other common symbols force your hands to abandon the home row entirely. Exotic keyboards can remedy all this, but lack portability.
Handalf is a 42-key layout scheme that works well for a Corne or any other fancy keyboard with 3 thumb keys per hand, but it also fits perfectly 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 fully consistent layout, even when you're stuck on a laptop keyboard.
- Easy to learn. Your alpha keys could be the same as what you're using now, and every other symbol is accessible with just the AltGr modifier. There is one additional layer for navigation, which can be combined with AltGr to get function and media keys. There's no need to learn it all at once: I've found the symbols under AltGr to carry the most ergonomic benefit.
- Overloading is used sparingly. While typing at speed, keypresses will often overlap, which means that any attempt at assigning multiple functions to the spacebar or home row must resort to fiddly 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. Only a single key is given double duty, and it is chosen with caution and care.
- Stateless. Modal editors are great, but only because they can provide continuous feedback about the current mode. We should strive to make the keyboard a perfect interface between the brain and the computer; you should never be expected to glance down or to think: 'what was I doing again?' The feedback available to your brain is strictly tactile, in the physical position of your hands. Therefore, emitted keys will depend only on the keys you are currently pressing, and, at most, which key you were pressing some fraction of a second ago.
- Low mental load. Modifiers and layers should behave identically from the user's perspective. They should stack in an intuitive and consistent way. Sticky keys may last for one keypress at most.
- Complete. When stuffing so much functionality into a cramped space, it is inevitable that some key sequences will become harder to type. However, our 42 keys should give access to every key that you might find on a standard tenkeyless keyboard. I have avoided assumptions about the software you will be running, and yet tried to find an arrangement that makes sense within the established software ecosystems.
Above all, the layout should feel good. Many ideals are taken into consideration, like rolling motions, muscle memory, semantic clustering, symmetry, separating actions from symbols, etcetera --- but the final decision is based on vibes. If it's a good mapping, it will almost immediately render its absence on other keyboards painful.
Unfortunately, Handalf is biased toward right-handed people. Let me know if you have a left-handed layout following the same principles.
Many lower-end keyboards, and in particular integrated keyboards on laptops, have limited rollover --- meaning that they cannot physically register all combinations of keys. Keep this in mind when you run into issues.
If you are currently using Colemak, Workman or good old Qwerty/Azerty, then all alpha keys can stay put. 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.
While pressing AltGr, the left-hand side of the keyboard provides 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, the one that would have been your Alt, is now the Fn key. This key accesses a layer for keys that perform actions rather than symbols.
Here, the navigation cluster is placed so that you can control the directional keys with only your left hand.
The keys on your right hand are the usual letter keys augmented with both the Alt and Meta modifiers. This is intended to be used for custom window manager shortcuts.
F-keys and media control keys are obtained by combining the Fn layer with the AltGr modifier.
Numpad keys have been left out of the layout for now.
BkSp takes the place of CapsLk, avoiding the huge move your pinky would have had to make.
CapsLk, in turn, can be activated by pressing both left and right Shift (or double tapping Shift).
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: to make it do something else when it is tapped in isolation.
If you are a Vim user, one key in particular might come to mind. Indeed, it is entirely reasonable to overload Fn with Esc. It tends to punctuate your keystrokes, so you generally don't need to muck about with timings to disambiguate your intent.
However, accidentally triggering Esc can be really annoying. Outside of Vim, it wreaks havoc by closing windows, losing focus on input fields, and erasing the spreadsheet formula you just typed.
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 applications can then be explicitly configured to interpret this key in a useful way, so that the effect is limited to where it makes sense.
To interpret the key as Esc in your terminal emulator, confer
the relevant manual. For example, 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.
Of course, this approach also allows you to make it do something entirely different, such as configuring XKB to use it as Compose.
The Multi key (also called Compose) allows you to
type special characters by typing intuitive keys in succession. For
example, Multi=c becomes €.
It is virtual, in the sense that there is no physical key that has this property by default. You need to assign it on the software level.
In the Handalf XKB layout, Multi is assigned to the second
backslash, a neighbour to left shift on ISO keyboards. This is a good
choice because is not used for anything else in our layout, its
canonical position is already more or less where we want it to be, and
there exists a standard XKB option for it (namely compose:102).
It is put on the same position as left Shift, with the understanding that we prefer to use right Shift on the thumb in most cases.
The Fn layer contains dedicated Cut, Copy, and
Paste keys. This keeps these keys in the same spot regardless
of the layout of your alphanumerics, but more importantly: they can be
used in some terminal emulators (without the need to distinguish the
^C signal from copying).
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 keeps the window list in view, just as it would if you pressed the real Alt.
Furthermore, ShiftTab is commonly used to invert whatever Tab does --- be that indentation, input selection or text completion. To make this easier, AltGrTab (and thus AltAltGrTab) will do the same.
Modifiers are keys like Shift, AltGr, Ctrl, Alt, and Meta. These keys are sent along with the key you press, for your software to interpret. A layer key like Fn is similar, but it modifies the key directly, before it even leaves the (virtual) keyboard.
The position of modifier and layer keys is fundamental to the layout: they change everything your other fingers can do. Therefore, I considered many different permutations, eventually landing on the following insights:
- Ideally, these keys should be your thumbs' responsibility, because you have full range of motion with the rest of your fingers while holding them.
- The symbol modifiers, Shift and AltGr, should be on the hand opposite from Space. They don't need to be combined, so they can be on the same hand.
- The order in which you activate 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.
- It should be assumed that the fingers are in the home row position; shifting your fingers a column or row is not comfortable on sculpted keyboards like the Kinesis Advantage, MoErgo Glove80, Dactyl, or Keyboardio Model 100.
- When overloading a modifier, consider potential misfires: choose 'tap' and 'hold' actions that are not destructive. This is easier to do when associating the overloaded key with Window Manager actions.
Shift and AltGr are are modifiers that you use in the context of a longer sequence --- since they expose symbols rather than actions. 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!
In general, it doesn't matter whether you press the right or left variant of a modifier, so we choose the left variant when the key occurs on the the left side (left Alt) and the right variant when the key occurs on the right side (right Shift, AltGr, and right Ctrl).
But all variants should be available:
- Some tasks, like escaping a virtual machine, may involve tapping a specific side.
- I want to accommodate typing inconvenient modifier combinations, like CtrlShift, in which one of your thumbs is already occupied.
- Shift should be available to the left pinky still, because sometimes it needs to be pressed while using the mouse. Similarly, I want shortcuts involving Cntrl to remain easy to type with the left hand, even if your right hand is on the mouse, or if you're on a laptop keyboard without a thumb key for Ctrl.
Therefore, in the Fn layer, your left pinky accesses a sticky left Ctrl. The Fn layer itself is then temporarily disabled. This makes it very easy to hit common shortcuts like Ctrls.
In many operating systems and desktop environments, there exists a convention to open a global menu upon tapping the Meta key (also sometimes referred to as the Super, Windows, Command or GUI-key). On a laptop keyboard, right Meta is easy to tap, because you can press Fn with your left thumb and Space with your right one. But saner keyboards where the right thumb can't reach Space need a left variant too --- which is why the pinky also gets a non-sticky left Meta.
It does violate our design principles to hide modifier keys behind other keys. There are real downsides: you can't combine these modifiers with other keys in Fn, and typing complex combinations may cause you to pause to think. This compromise is acceptable, because these are second-class variants anyway; their thumb counterparts should be used in the general case.
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. Remappings can take place at any of these levels.
- 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.
- For layout-independent shortcut bindings, it is desirable that emitted keycodes stay the same even as the keysyms change.
- I have run into some applications that listen to keycode
- The major drawback to remapping symbols at the keysym level is that you need to install a layout to the system that you're using.
- On the other hand, the other approaches require that you have control
over the keyboard firmware or run a virtual keyboard like
keyd.
For maximum compatibility, Handalf remaps at the scan- or keycode level. Nevertheless, it also ships with an XKB layout that remaps AltGr symbols at the keysym level. Both approaches can be active simultaneously without issues.
The following section is only relevant for firmware implementations.
Keystrokes for control of the keyboard itself, such as those handling Bluetooth connectivity, should not obscure any keystroke that might be used by an applications. For that reason, they are hidden away behind combinations of keys on the same column. To avoid incurring any lag, this is further limited to when all left thumb controls are simultaneously pressed (that is, when the Alt and right Meta modifiers as well as the Fn layer are simultaneously activated).
For Bluetooth connectivity, the top two keys on columns 1 through 5 connect to the corresponding profile, the bottom two keys disconnect that profile, and pressing all three clears the profile. Keys on column 0 switch between USB and Bluetooth output.
Handalf uses some keys that are not present on standard contemporary keyboards. As a result, they may not be recognized out of the box by all applications, and not even all operating systems.
That is why a compatibility mode exists that replaces the funkier keys as follows:
| Key | Replacement |
|---|---|
| Cancel | Esc |
| Cut | CtrlX |
| Copy | CtrlC |
| Paste | CtrlV |
| Lock | MetaL |
| Close | AltF4 |
| Search | MetaS |
These keys are more widely recognized across all operating systems without further configuration, but you do lose out on some of the subtle benefits described in earlier sections.
Pressing the top two keys in the rightmost column (11) turns compatibility mode on, the bottom two keys turn it off, and pressing all three keys simultaneously will toggle it.
For the Linux software implementation for a laptop or non-programmable
keyboard, install keyd (version >=2.3)
and run sudo make install-keyd.
A firmware implementation for ZMK-based keyboards can be found in the zmk directory.
In either case, optionally do sudo make install-xkb and activate the
handalf XKB layout in your environment. This sets up the
Compose key and assigns the Level3 symbols to
AltGr.
More detailed installation instructions to come later.