Keyboard Builders' Digest
Save 5% at Typeractive! Code: KBDNEWS
Keyboard Builders' Digest / Tips & Tricks

Keymap wizardry: Typing out the Harry Potter saga

In this case study I type out the Harry Potter books to demonstrate the power of alternative layouts and keymap customization.

KBD.news
Published June 20, 2024
Creators! Feel free to tip me off about your keyboard related projects to bring them to 140K readers.

Typing out all the Harry Potter books would be crazy, right? What would be the point? Seems like a weird flex even by keyboard enthusiast standards. Yep, that's right. Typing out the saga once makes no sense at all. That's why I'm going to type out the books a few million times! For the benefit of humanity and especially of you, fellow keymap wizards.

This is a demonstration of the power of alternative/custom layouts. Given the huge extent of this topic, we can barely scratch the surface here so consider this write-up a mere teaser.

Imagine you are an aspiring writer with a brilliant idea, just about to start typing out your magnum opus, staring at a yet empty document on your screen. Cursor blinking, annoying orphan relatives locked up in the cupboard under the stairs.

Your story, about a young boy who ends up saving the world, is quite complete. You "just" have to type out heaps of your manuscripts and notes: about 6.5 million keystrokes (fingers crossed you don't make ANY typos).

Pic:

Everything is prepared for the typing session: you have the best ergonomic chair, the best word processor for writing, the ultimate playlist, and you even acquired a fancy mechanical keyboard, but… I fear you missed one important aspect: your keymap!

It's highly likely that your keyboard is the standard QWERTY one and you haven't even considered to jumble all the letters, right? Why would you do this?

Because alternative or fully custom layouts may significantly boost your typing performance, shorten the distance your fingers will have to travel, and make typing much-much smoother.

Fun fact: typing out the full Harry Potter series on a standard QWERTY keyboard means your fingers travel about 144 km. Which you can bring down to 76 km simply by rearranging the keys on your keyboard.

Does a keyboard layout very different than QWERTY sounds scary? Absolutely. In full honesty: changing layouts may feel like learning to walk again. That's why, even before taking the first step, we will investigate various layouts which can help you or could have helped the not-yet-famous J.K. Rowling on her way: to decide if the gains are worth the time and effort you'll have to put into relearning typing.

As I'm writing this, I haven't typed or evalueated anything yet so I have no clue if there will be significant differences or even the slightest improvement in efficiency when using a really custom logical layout. (Spoiler alert: All right, based on all those years spent with creating and using custom keymaps I strongly suspect that there will be some improvements, a huge one to be honest.)

Anyway, let's demonstrate either the power and superiority or the miserable failure of logical layout design by giving you exact numbers so you can decide it for yourself if alternative and custom layouts are worth the hassle.

Most people may not even be aware that alternative layouts exist. Or know only Dvorak or Colemak. Actually, there are countless layouts out there, and some of them are great! However, learning a new layout involves retraining your muscle memory and may really feel like learning to walk again. I hope this write-up will help you to decide if the gains are worth the effort.

The way of the wizard

Using basic language statistics while typing out the books (mostly letter, bigram and trigram frequencies) we investigate keymaps for various indicators: total finger travel, keypresses in the home row, row changes, hurdles, hand alternation, rolls, etc. Usually you want a healthy balance of these.

Of course there are more sophisticated and obscure indicators like redirects, scissors, DFB/SFS (disjoint or same finger skipgram) or LSB (lateral stretch) - but let me keep things simple for now.

Below you can find the results of the evaluation of just a few well-known example layouts, side by side. Lean back for a minute and take your time to digest the numbers and what they mean considering especially your personal typing habits.

Pic:

How could we find better layouts?

How to decide if one layout is better than the other? Many people do this intuitively, tweaking their keymaps perpetually, swapping some characters and checking the results.

A more sophisticated approach is to use dedicated optimization tools (algorithms and models), which do the job in an automated way, handling a huge number of potential layouts to find the best one given the physical layout, corpus and ruleset.

Regardless of the exact method used, the evaluation phase is similar to this:

  • We have to type out the same text (corpus), this time Harry Potter, by using each layout.
  • While doing this, we count the occurrences of all the weird and uncomfortable character combinations (language stats) which we would like to avoid, and also the smooth and desirable ones we'd like to encounter more frequently.
  • Summing up penalty and reward points we'll have to use some kind of exchange rates between various metrics (ruleset) so we can distill all the indicators and eventually represent the layout with a single score.
  • This makes it possible to compare all the layouts and declare the final winner: the layout with the lowest score (fewest penalty points).

Pic:

Christopher Latham Sholes, inventor of QWERTY, did something similar when working on his typing machine back in the 1860-70s - counting letters and bigrams by hand, using pen and paper. August Dvorak and his team too.

However, we are much luckier than our predecessors: thanks to our magical devices called computers we can compare thousands or millions of layouts in a realistic time-frame of mere minutes. That's how we can "type out" Harry Potter a few million times. (Sorry if you feel deceived.)

Putting improvements into context (% to keypresses)

So how to interpret the numbers above? What does a 1% or 0.1% (or 9 3/4) difference really mean? Are they significant? I found that it's easier to comprehend these values in the context of everyday metrics: keypress per page or line.

E.g. the average line of text, with optimal readability in mind, is about 55-60 characters. We could agree on 50 characters for easy mental calculation, so roughly about 2% difference means one keypress less or more per line. That's huge, and e.g. we improved keypresses in the home positions by 30%! That means 15 more keypresses per line without even moving your fingers!

Pic:

Similarly, we can define the average page as, say, 2,000 characters. This means a difference of 0.05% (1/2000) in any index will appear as one more/less keypress per page. Significance in these (and not statistical) terms is relative and depends on your preferences, but this is where I personally draw a line: anything occuring or not occuring at least once per page is insignificant for me. It could be once per 1,000 characters i.e 0.1% too, or every five rows (300 characters or 0.33%).

QWERTY

What we cannot see in the first table so you'll have to trust me on this: QWERTY is not bad at all. It's in the top 2% of all potential layouts (2.7x10^32 in the 30-key examples) which is pretty impressive given it was designed one and a half centuries ago. This of course does not mean that there's only room for 2% improvement. In the practically endless number of permutations 2% means endless number of better alternatives, some of them way-way better in any terms.

Pic:

DNT

Taking a look at the heatmap above, you may feel compelled to improve the layout by putting some frequent letters in the "right place". E.g. the layout I call DNT is the result of the most straightforward three letter swaps: D-E, N-J, T-F. (There are other obvious choices but they may introduce some unexpected effects.) All these letters stay on the same fingers so the layout is very easy to learn.

Pic:

The best thing? With this minimal effort we can gain 50-60% of the potential improvements of some well-known alternative layouts. Simplicity of this intuitive design comes of course with some drawbacks and missed opportunities.

Dvorak, Colemak-DH, etc.

Dvorak and Colemak - just to name some mainstream alternatives - are better at the expense of completely messing up the layout, requiring much more time to master. Some indicators of these two layouts are pretty similar: e.g your fingers could travel about 40-45% less (6 km instead of 10 km while typing out the first book, Harry Potter and the Philosopher's Stone). Really impressive, you just have to decide if you prefer more hand alternation with less row changes (Dvorak)…

Pic:

…or less samefinger keypresses and travel (Colemak DH):

Pic:

I don't really want to endorse specific layouts here. There's no "best" layout, in the end their performance depends on your personal typing habits and preferences. That said, there are many notable layouts out there for English (e.g. engram) or other languages: BÉPO for French, Neo for German, Romak for Portuguese, etc. No room to introduce everything in this write-up, feel free to check them out for yourself.

Custom layouts

But why would we stick to layouts designed by others? You can squeeze out even more performance by going fully custom, creating a layout for yourself. Programmable mechanical keyboards and fancy GUIs like VIA/Vial make experimenting very easy.

E.g. I love rolls even if it means sacrificing some other indicators, so the last column in the table above is a custom layout optimized for Harry Potter with a ruleset favoring rolls.

Pic:

In addition, the books have some significant differences in letter frequencies compared to "average English", so a custom layout may easily beat mainstream alternative layouts based on a generic corpus.

With Harry, Hermione and Hogwarts occurring all the time, it's no wonder that "H" makes it to the 8th place of the letter frequency chart - deserving a prominent home position!

Potential gains

Other than the layouts above, for the sake of science, I calculated the potential gains too, focusing on individual indicators. This means we don't bother with bringing all the numbers to a common denominator but calculate with only one parameter at a time, ignoring all the others.

Here are the results for the first Harry Potter book:

  • Finger travel: 10.37 km → 5.46 km (-47.37%) Quite a start!
  • Home row: 26.1% → 59.25% Nice!
  • Min. samefinger: 3.89% → 0.25 Wow!
  • Min. hurdle: 6.49% → 0.06% OMG!
  • Max. rolls: 3.61% → 12.9% Yummy!
  • (Max. inner rolls: 1.93% → 10.42%)
  • Max. alternation: 52.87% → 70.07% If you fancy this.

(The numbers are based on a non-deterministic genetic model so they may be further improved. Slightly.)

Too good to be true, right? 6-7 comfy rolls in a single line? Encountering a pesky hurdle only once per page? Not even leaving the home positions for 6 out of 10 keypresses?

Sadly, since some indicators are antagonistic, achieving these numbers at once is impossible. Nevertheless, this may serve as a good reference when comparing our more realistic, aggregated layouts.

Is it worth it?

Based on the results above, I'd say changing to an alternative layout should be a no-brainer. The real question is only: which one?

  • If you type in English and are still on QWERTY, all options are on the table: Dvorak, Colemak, other alternative, custom.
  • If you're already an experienced user of Dvorak, Colemak or anything similar (still typing in English), you are most likely good and could expect relatively little improvements from a custom layout unless your preferences are special.
  • However, the vast majority of the human population uses multiple languages, with English being only a second or third language. In this case I'd suggest looking into fully custom layouts.

Remember: all the numbers and heat-maps in this write-up are only valid for the Harry Potter books. Other English texts may result in slightly different scores and optimal layouts, not even mentioning other languages.

In this series we will look into the logic and means of creating custom layouts from scratch, tailor fit for your typing habits – whatever language you use.

Conclusion

Originally, I didn't want to convince you of anything, but the numbers speak for themselves. As this case study hopefully demonstrated: Alternative and custom layouts may dramatically improve your typing experience. Your typing habits are unique, average English doesn't really exist on the individual level, so there’s a chance that popular layouts are not the best option for you. All in all, feel free to experiment with alternative layouts or come up with your custom one.

How exactly? Let's see some tips, exact steps (and warnings) next time.

(Before you ask: the keyboard in the illustrations is Moeetech's Glitter65, with Aihey Studio's Slytherin keycaps).

Do you like this post? Share, donate, subscribe, tip me off!

Published on Thu 20th Jun 2024. Featured in KBD #167.


Tags: keymap

Related

The SpaceFN concept

The SpaceFN concept - setting up your space key as a layer switch when held - is probably one of the most useful tweaks in the keyboard hobby. Let me explain it.

Caps Word and other QMK tips

A QMK keymap with short blog posts by Mental_General_5445 explaining tricks like autocorrection, Caps Word, getting Shift keys right, etc.

Mantis: Hexagonal Keys in Ergonomic Keyboards

Felix Kühling explains how hexagonal keys work surprisingly well in an ergonomic layout without fine-tuning parameters like hand rotation, column stagger and splay.

Lexicon keyboard

Lexicon is a 65% "writing keyboard" designed by Ewen Cluney – with a layer full of whole words.

M4CR0Pad in action

I tested the M4CR0Pad by Ergohaven and thought it would be interesting to demonstrate the ease of setting it up, along with a typical use case.

×
top