Designing the Ultimate Keyboard Layout

Warning: Some of this info is out of date. Up-to-date information can be found here.

Preface: I am not very good at HTML, so sorry that this page is a bit ugly.

At this page I have a bunch of tips on manually designing a layout.

SOME STUFF YOU MIGHT WANT TO KNOW BEFORE READING THIS:

-A digraph is a group of 2 letters.
-A trigraph is a group of 3 letters.
-Here is letter frequency I have determined based on 2000 pages of widely varied text (news articles, essays, programming code, discussion boards, as well as others)
E TAOINSRH LD CUMGFYPW.B,VK' XJQZ;
A space means that the keys before and after are widely separated in frequency. For instance, E makes up 13% of text and T makes up only 9%. Fun fact about letter frequency: ETAOINS make up more than half of all letters.
I'm using information from many other keyboard design projects, which can all be found here. They try to design the best keyboard layout based on certain critera. These criteria are common among most of them:

-Reduce travel distance: K and F are easier to type than E and M, which in turn are easier than T and B.
-This implies that the most common keys (ETAOINSR) should be on the home
row.
-The hardest to reach spots are Q, Z, P, /, T, Y, and B.
-Stronger fingers should be used more. My idea of good proportions is 9% for the pinky, 12% for the ring, and 14-15% for the middle and index.
-Using the same finger twice is hard: CEDED
-Some say you should maximize alternating hands to avoid this: SEVEN STEWARDESSES SEW SEVEN SWEATERDRESSES
-Some say you should maximize hand rolling such as: asdf, oiu
-Most say that rolling inward is easier than rolling outward
-Some think rolling outward should be avoided, and others say it's okay, just not as good as rolling inward. (I agree with the latter.)

I basically agree with all these, and have a comment later on about hand alternation versus hand rolling. Here are all the other things that were noted on by not
very many layouts, in rough order of popularity:

-Moving from the top to the bottom row or vice versa is hard: MINIMUM
-Try to keep keyboard shortcuts such as Z,X,C, and V in an easy position.
-Keep it easy to learn from people who know QWERTY.
-Changing rows on the same hand is hard: SE, LU
-Moving to the center column on the same hand is hard: HI, EG, LY
-Typing two keys on the same hand that are non-adjacent is kind of hard: AD, J;
-I personally disagree with this, except for pinky-middle; jumping over the ring finger is hard due to lack of the ring finger's flexibility
-moving up and out along the same hand is hard: QS, UK. This is because, in the hand's natural arc, the middle and ring fingers extend farther. Typing like this bends the fingers beyond the point of comfort and "warps" the hand.
-That one I personally added but no one else had

My program does not attempt to make a keyboard that is easy to learn or one that retains keyboard shortcuts. I have created a few layouts by intuition and not by a program, and in those I usually try to keep the keyboard shortcuts in place, but it's low priority so I won't sacrifice anything else to keep them in place.
Using this information, I am using a computer program to generate the best possible keyboard layout.

SAME HAND VERSUS HAND ROLLING

Using one hand too much does get annoying. However, rolling inward on one hand feels a lot better than alternating hands. So how is this balance to be reached? At first, I had my computer program add to the score if the same hand is used for more than two keys in a row, unless the fingers were rolling inward. But later, I came up with a better solution. It only counts as same hand use if it's reversing direction. Each direction reverse adds to the layout score. The way this works: The hand can move comfortably in one direction (ASDF). But if it tries to go the other direction, it gets confused, slows down, and is prone to error. (asdewa)

MY REVIEW OF THE BEST LAYOUTS OUT THERE

Roughly in order from best to worst based on my judgement/my algorithm.

		OIST by me
		score: 10.54
		. y c p k  b l u w ,
		o i s t d  h n e r a
		z x v g q  f m ' j ;
		

This is a layout that I designed without the aid of a computer program. It has the best same finger of any keyboard here, but has pretty bad same hand. Z, V, and X are close to their original positions and still easy to use as shortcuts, and C is still fairly easy. This layout also has a lot of good rolls, like IO(think 'tion', a common word ending), IS, ST, ER, and RE, all of which are very common.
		COLEMAK by Shai Coleman
		score by algorithm: 11.95
		q w f p g  j l u y ;
		a r s t d  h n e i o
		z x c v b  k m , . /
		

Colemak is meant to be easy to learn from QWERTY. It has the best same finger ratio of any keyboard layouts not made by me. The most common keys are on the home row, and less common keys are on less common positions, the biggest problem being B, which is left in place to make it easy to learn. Overall, this is a very good layout.

		ARENSITO by Hakon Hallingstad
		score: 12.48
		q l , p '  ; f u d k
		a r e n b  g s i t o
		z w . h j  v c y m x
		

Arensito has third best same finger. It would be better except that it put comma and period on the same finger as E, and E is a very common last letter in words, so it will frequently be followed by period or comma. It doesn't keep some of the keyboard shortcuts in the same place. An advantage is that it's the layout that has the most inward rolls of any of the best layouts.

		CAPEWELL EVOLVED LAYOUT by Michael Capewell
		score: 12.71
		. y w d f  j p l u q
		a e r s g  b t n i o
		x z c v ;  k m h , '
		

This layout was designed using an evolutionary algorithm, and is one of the best. It has very good same finger, but overuses the hard-to-reach bottom row by putting H there.

MALTRON by the people at maltron.com (Okay I admit it, I don't know who made it.)
Maltron Layout is another very good layout, but because it requires a special keyboard, I cannot use it with my algorithm and do not have a review.

		KLAUSLER'S EVOLVED LAYOUT by Peter Klausler
		score: 12.64
		k , u y p  w l m f c
		o a e i d  r n t h s
		q . ' ; z  x v g b j
		

This is the first ever layout designed by computer algorithm. It was made in an attempt to beat QWERTY, but the creator (last name Klausler) thought Dvorak was better. This layout has no outright flaws, but isn't as good as some of the others. Same finger on the left index is kind of high.

		DVORAK SIMPLIFIED KEYBOARD by August Dvorak
		score: 15.22
		' , . p y  f g c r l
		a o e u i  d h t n s
		; q j k x  b m w v z
		

This was the first alternative layout, designed in the 1930s. This layout has some good rolls like NT and TH, and has the best hand alternation. It overuses same finger though, and puts a little too much stress on the right pinky. There are a few distance issues; R and I are not on the home row, and they should be because they are more common than H and U.

Here's my (almost) latest version of the scoring program, in order of importance. (Higher scores are worse.)

		-Each position has an assigned cost: 
		66 35 29  33  60 91  33  29 35 66
		0 -8 -10 -10  40 40 -10 -10 -8  0
		96 72 60  48 109 48  48  60 72 96
		

I decided on those values by measuring the horizontal and vertical distance between each key on a standard keyboard. I then multiplied the horizontal and vertical distance, with the proportions changed based on the strength of each finger. The horizontal distance was magnified for the middle and ring fingers because they are not good at moving sideways, only forward and backward.

  • Using the same finger twice costs 60.
  • Using the same hand and reversing direction costs 1.
  • Jumping over the home row costs 50, unless it's using the index finger on the bottom row, in which case it only costs 10. (Type VE, it's not too hard.)
  • Moving to the center without switching hands costs 10.
  • "Hand warping" costs 4.
  • Changing rows costs 10.
  • Rolling inward along one hand subtracts 2 from the score, and rolling outward subtracts 1.
  • I noticed that, throughout my creation of these values, I had to reduce some of them by a lot. The cost for same hand had to be very low, because it is such a common issue. It tends to take over the entire layout, making the same finger ratio or finger travel distance a lot worse. In the end, I made finger travel distance a lot more costly so it would actually put common keys on the home row. I kept all the values high enough so that they would still affect the layout. Even though same finger is a pretty rare occurrence, it still makes the layout so that very uncommon key combos are on one finger, like UE. You can't tell that the same hand is affecting anything because it's hard to see by looking at the layouts, but it does a fairly good job of reducing same hand. Since this was kind of messing up my layout, the solution I reached was to make the home keys have a negative cost. This way, it would be very sure to place the most common keys on the home row.

    MTGAP'S LAYOUT

    I use a computer program to determine the best keyboard layout. Mainly, I am dealing with the 30 standard keys: a b c d e f g h i j k l m n o p q r s t u v w x y z . , ' ;
    I might at some point include the shifted form, but right now that's low priority because most keys are lowercase, and anyway uppercase letter frequency is about the same as lowercase. Plus I tried and I was getting annoying bugs. :)
    Almost as important are the "big" keys: space, delete(I am using a Mac), shift, return, caps lock, and tab. However, there are so few of these that using an algorithm would slow it down more than it would help. There are 30 factorial (30 x 29 x 28...) combinations with just the main layout, but if you include these 7(with 2 shifts), there are 37 factorial combinations, which is about 51000000000 times more. But it's simple enough to place those using human logic. And if you have an ergonomic keyboard, those keys can be put on the thumb pads. If you have thumb pads, you only need 1 shift. The purpose of having two shifts is so that you can type something that's on the pinky while holding down shift, and if shift is typed with the thumb, this is unnecessary. So if you have thumb pads, I'd put space under the right thumb, delete under the left thumb, shift off to the side on the left thumb, and return off to the side on the right thumb. Caps lock and tab are both pretty rare, so I don't really care where they go. (This description helps if you look at a picture.)

    HOW THE PROGRAM WORKS

    You can't possibly go through every possible keyboard. The home row has 3.6 million combinations, the main 30 keys have 2.6*10^32 combinations, the non-numbers keyboard has 1.2*10^61 combinations, and the whole keyboard has 1.3*10^80 combinations. This is waaaay too many to look at all of them. So an evolutionary algorithm is the most efficient way to find the best keyboard without actually going through all of them.
    The program has basically 3 parts: the scoring program, the keyboard program, and the evolution program.

    KEYBOARD PROGRAM
    This one's pretty simple. It generates a keyboard, and is in charge of rearranging all the keys on the keyboard.

    SCORER PROGRAM
    The scoring program runs a keyboard through it, and uses the scoring algorithm described above. It reads a text file, and scores the layout based on the letters it gets. At the end of the file, it divides the score by the number of characters in the file. This way, if there are 2 different sized blocks of text with the same letter frequency, a layout will score the same on both.

    EVOLUTION PROGRAM
    This one is the most complicated.
  • It creates a bunch of layouts and scores them all using the above methods.
  • It then kills the worst 1/2 of them.
  • On each remaining layout, two keys are swapped. The swapped versions as well as the original are scored.
  • Repeat steps 2 and 3.
  • Stop repeating after the same layout has been the best 20 times in a row. After 20 times, you can be pretty sure it's not going to come up with a better layout.
  • WHY A COMPUTER PROGRAM?
    Creating a keyboard layout by hand is certainly easier. A program relies on its scoring system, and creating a well balanced scoring system is much harder than working off intuition. (I would know.) So why bother with a computer program? You could say it's because a computer can make a layout much faster than a person can. But I think the biggest advantage is that a computer is the ultimate multi-tasker. What I mean by this is that a computer can simultaneously balance every aspect of a layout to an extent that no person can.

    New Developments

    I soon discovered a flaw in the position costs. Presumably because the cost for same finger was too high, it was putting two vowels on the same finger, which not only increases effort but adds a lot of stress to that finger. I lowered the cost of same finger to 25, but that ended up being problematic because it was then undervalued, causing same finger to be way too high. But I soon realized that this was not the problem. The problem was that the costs for off home row movement were too low! So I changed the position costs to this.

    66 35 29 33 60 91 33 29 35 66
    0 -8 -10 -10 40 40 -10 -10 -8 0
    96 72 60 48 109 48 48 60 72 96
    This way, it is vastly better to be on the home row than anywhere else. I then increased all the other values like so:
  • Using the same finger twice costs 65.
  • Using the same hand and reversing direction costs 1.
  • Jumping over the home row costs 50, unless it's using the index finger on the bottom row, in which case it only costs 20. (Type VE, it's not too hard.)
  • Moving to the center without switching hands costs 10.
  • "Hand warping" costs 0.
  • Changing rows costs 10.
  • Rolling inward along one hand subtracts 10 from the score, and rolling outward subtracts 5.
  • These values are much more ideal because they didn't have to be artificially reduced.

    Ergonomic versus Standard keyboard

    Should the optimal layout be designed for a normal keyboard or an ergonomic one? The current version I have is meant for a normal keyboard, because that's what most people have. But with a few simple modifications, the program can make an optimal layout for an ergonomic keyboard. I will make an optimal keyboard for both.

    I have, using the above scoring system, created the first optimal layout. There are 4 factors that can change what's optimal: it can be optimal for an ergonomic keyboard or a standard keyboard; can be easy to learn from QWERTY, or can leave this off in order to make the layout better; it can keep keyboard shortcuts easy, or can not do this so as to make the layout better; it can use the entire keyboard, or just the main 30 keys. This layout is optimal for a standard keyboard, just the main part, and restricts shortcuts but not QWERTY positions.

    k g l d b j h u f .
    r o t s w m n e a i
    z x v c q y p , ' ;

    This layout has very good finger travel distance and very good row jumping. The same finger is higher than on many layouts, but I think it's worth it for the really low travel distance. I ran it through a program I made designed to improve layouts, and it made no improvements at all. This is THE best layout with my scoring system, and I spent a long time making sure the scoring system was very good. I will not be providing a way for you to use this layout, for although I think it's really good, I want Colemak to take over QWERTY, and having too many layouts will not help QWERTY get conquered. So go download Colemak if you want to use a good layout.
    The most annoying digraphs and combinations are:
  • men
  • he
  • pen
  • All other layouts I create can be found here.

    6/17/08 Update:
    Through learning MTGAP's Standard Layout, I have realized that the [QWERTY] V position is harder to type than I thought. I switched the M and P keys to make this easier. I also modified the algorithm so that the V position costs 54 instead of 48 in case I want to run it again.

    6/18/08 Update: I have been using MTGAP's Standard Layout, here's what I think so far:
  • The hand alternation is very good.
  • I was worried that the cost of row changing was too low, and that having common stuff on the top row would increase row changing. But it's comfortably low, due to hand alternation. The most common are TH and HE. E and T are on different hands from H.
  • I love having H and L (the 2 most common keys not on the home keys) on the middle and ring fingers, they are so easy to reach!
  • Same finger, though not as low as Colemak, is comfortably low.
  • Hand warping is also plenty low.
  • There are not very many rolls.
  • MTGAP's Standard Layout version 2.0

    I've made some revisions to the scoring system based on how I felt typing on the other layout. I increased the value of inward rolls to 10 and outward rolls to 5, because I felt that there were far too few of them. I also increased the cost of jumping the home row with the index finger from 10 to 20, because although it is easier than with any other finger, it's still kind of hard. I also noticed that the QWERTY positions V and N are harder than I thought, so I increased their costs from 48 to 54. I also eliminated hand warping, because it's hard to change rows at all. So here is the new version:

    , f h d k j c u l .
    o a n t g m s e r i
    q x b p z y w ' v ;

  • Same finger is lower than any other layout I've done, nearly as low as Colemak.
  • Hand alternation is about as good as Colemak, with such digraphs as HE, IN, EN, and others.
  • Rolls are much better: ER, RE, ES, NT, AN, ON, IR. There are also some non-touching rolls like TO, IS, AT.
  • I've been using this layout all day. The rolls are nice. Row changing is a bit high, but that's pretty minor. The biggest problem is the location of , and . but only because I'm not used to it. This is a pretty amazing layout overall, and I have decided to make it the final version. If you see any problems with it, let me know. (See bottom of page.)

    This layout is designed with the unevenness of the standard keyboard taken into account, but it should still be very good.

    Is this layout really the best?

    How can you know if a layout is the best? I am always skeptical of my own layouts; I've seen too many bad layouts that thought they were good. I don't know if this is the best possible layout, but I do know it's the best I've ever used.

    If you want to download my code, you can get it here. They are written in Ruby. Here's what each file does:

  • genetic_algorithm2.rb is the main program that runs the algorithm. Lines 571 to 580 determine how long it runs for. The current values are such that it takes about 6-9 hours to finish on a 2 ghz processor (which is not that long, trust me), and are also accurate enough so that if you run it twice you will get 2 very similar layouts. Increasing the stats a lot won't help a whole lot. The most variable one is @layoutnum, you can change it a lot and not change the outcome much. So if you want it to go faster reduce @layoutnum to 32 or something.
  • keyboard1.rb manages the keyboards.
  • scorer6.rb is called by every file except keyboard1, and scores the keyboards.
  • calculator.rb gives a user-friendly view of different layouts. At the part where it says stuff like this:
  • score("MTGAP's evolved standard layout", @tea)
    You can put a pound sign before that line to basically make that line not exist, so it won't score that layout.

  • improver.rb improves on a keyboard that you give it according to its criteria. A keyboard is a thing that looks like this:
  • @qwerty = {
    'q' => [0,0],
    'w' => [0,1],
    'e' => [0,2],
    'r' => [0,3],
    't' => [0,4],
    'y' => [0,5],
    'u' => [0,6],
    'i' => [0,7],
    'o' => [0,8],
    'p' => [0,9],
    'a' => [1,0],
    's' => [1,1],
    'd' => [1,2],
    'f' => [1,3],
    'g' => [1,4],
    'h' => [1,5],
    'j' => [1,6],
    'k' => [1,7],
    'l' => [1,8],
    ';' => [1,9],
    'z' => [2,0],
    'x' => [2,1],
    'c' => [2,2],
    'v' => [2,3],
    'b' => [2,4],
    'n' => [2,5],
    'm' => [2,6],
    ',' => [2,7],
    '.' => [2,8],
    '\'' => [2,9]
    }
    Change the letters inside the apostrophes to change what key is in that position. You have to have a backslash before an apostrophe, as seen on the last line (at spot 2,9). You can change keyboards in the same way in any file, I'm just telling you how to do it with this file in case you want to use my scoring system to improve on a layout of your own.
  • allthetrigraphs.rb is a file read by scorer, don't mess with it.
  • trigraphs.rb can read a file and make a list of trigraphs. What I did was read a very large file, and put all the trigraphs with frequency of over 1000 into allthetrigraphs.rb, and use it to score the keyboards.
  • To run these programs you need to know how to run Ruby programs, and I'm not going to tell you how to do that because I'm lazy. But that's what google.com is for. :)

    If you have comments about my programs or anything on this page, post them here.

    Here's some more interesting stuff.

    This is a layout with same finger penalty on maximum. This way you can know the best groups possible in order to reduce same finger. You can still have very low same finger without these groups, but this is the lowest possible.

    x w d f b k h u ' .
    o r t s c l n i e a
    z ; g v q p m y j ,

    Same finger
    Finger = 1.75%
    Colemak by Shai = 2.18%
    Arensito by Hakonhal = 2.21%
    MTGAP's evolved standard layout 2.0 = 2.45%
    Michael Capewell's Evolved Layout = 2.65%