Click to view our Accessibility Statement or contact us with accessibility-related questions

Keymap wizardry: Typing out the Harry Potter saga

more_vert
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 it out once makes no sense. 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.
search


This demonstration of the power of alternative/custom layouts is a shortened version of the original article at kbd.news. 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.
search
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. Most people may not even be aware that alternative layouts exist – yep, other than QWERTY. Or know only Dvorak or Colemak. Actually, there are countless layouts out there, and some of them are great! However, learning a new layout may feel like learning to walk again. I hope this write-up will help you to decide if the gains are worth the effort. What to look for? 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.
search

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).

search


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? 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.

search
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. 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.
search


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.
search
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). Really impressive, you just have to decide if you prefer more hand alternation with less row changes (Dvorak)...
search
...or less samefinger keypresses and travel (Colemak DH):
search
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 You can squeeze out even more performance by going fully custom, creating a layout for yourself. Programmable mechanical keyboards 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.
search
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.
  • 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.

Conclusion 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.
(Edited)
4
2
remove_red_eye
2.2K
dovenyi
77

search
close
Kenshiro70
137
Aug 2, 2024
In your next article with tips and tricks, could you list out keycap profiles which are most compatible with custom layouts? That tends to be one of the thornier issues when going off the beaten path. Also, if there are ready-made tools which can automatically take exported text files of stuff I've written and produce an analysis, that would be great. I've seen prior articles which used python scripts, but I'm not sure most people would brave the vagaries of github just to get those results.
Kenshiro70
137
Aug 2, 2024
Great article! Would it be possible to put the scores into a spider graph? That might make it easier to visualize the differences you highlight and make comparisons between layouts a little more stark. Try two versions - one with absolute values and one with percentage gains versus QWERTY - and then you can decide which illustrates your points best.
(Edited)
Related Posts
Trending Posts in Mechanical Keyboards