April 2006

A Programmer's Keyboard Layout

Preamble

Assumptions

Solution

The Cost Function

    «
    »
    Q
    q
    W
    w
    E
    e
    R
    r
    T
    t
      Y
    y
    U
    u
    I
    i
    O
    o
    P
    p
    {
    [
     
     
    A
    a
    S
    s
    D
    d
    F
    f
    G
    g
      H
    h
    J
    j
    K
    k
    L
    l
    :
    ;
    "
    '
     
     
    Z
    z
    X
    x
    C
    c
    V
    v
    B
    b
      N
    n
    M
    m
    <
    ,
    >
    .
    ?
    /
     
     

    Cost 2.48 per keystroke

    «
    »
    "
    '
    <
    ,
    >
    .
    P
    p
    Y
    y
      F
    f
    G
    g
    C
    c
    R
    r
    L
    l
    ?
    /
     
     
    A
    a
    O
    o
    E
    e
    U
    u
    I
    i
      D
    d
    H
    h
    T
    t
    N
    n
    S
    s
    _
    -
     
     
    :
    ;
    Q
    q
    J
    j
    K
    k
    X
    x
      B
    b
    M
    m
    W
    w
    V
    v
    Z
    z
     
     

    Cost 2.35 per keystroke

Pure Java Keyboard

First we start with what a pure Java keyboard would look like. I used all Java programs I had written as a sample (53K lines ending with semi-colon or have close brace " "). Comments are included, but the licensing comments at the top of each have been removed.

Here are the most common digraphs (per million digraphs):

    / / 30902
    ;   16848
    i n 12737
    t e 10723
    n t 10009
    e t  9785
    l e  8805
    ) ;  8654
    e r  8347
    a t  8153
      i  7695
    i c  7380

    o r  7197
    t    7116
    s t  7059
    r a  6736
    e n  6714
    n d  6391
    ,    6047
    l i  5998
    p u  5879
    b l  5875
    a r  5858
    c    5775

      p  5709
    t i  5544
    ( )  5523
    r e  5461
    o n  5422
    g e  5343
    c t  5303
    r i  5269
      }  5225
    u b  5225
    {    5206
      a  5169

Notice that Java code makes no use of the most common English word, "the", therefore the "th" digraph is relatively rare. I believe the some other pairs can be explained

    K
    k
    S
    s
    H
    h
    C
    c
    _
    .
    G
    g
     
     
    W
    w
    F
    f
    /
    =
    }
    ]
    *
    [
    :
    |
    <
    -
    O
    o
    R
    r
    I
    i
    N
    n
    D
    d
     
     
    V
    v
    L
    l
    E
    e
    T
    t
    A
    a
    X
    x
    \
    !
    M
    m
    P
    p
    U
    u
    B
    b
    J
    j
     
     
    Y
    y
    '
    {
    ,
    ;
    "
    )
    +
    (
    >
    &

Less-Pure Java Keyboard

    / / 18341
    e   13834
    i n 12267
    ;   10083
    t e  9595
    t    9176
    e r  9005
      t  8661
    a t  8491
    n t  8026
    l e  7774
      i  7732

      a  7635
    r e  7402
    t h  7307
    o r  7138
    e t  6939
    o n  6832
    s    6710
    a n  6446
    e n  6334
    s t  6249
    ,    5939
    t i  5926

    a r  5863
    n d  5768
    i c  5443
    n    5424
    n g  5302
    r a  5216
    ) ;  5119
    h e  5105
    e s  4993
      p  4882
    d    4842
    o u  4747

|
]
\
(
"
)
+
;
-
{
Y
y
 
 
W
w
G
g
H
h
C
c
_
.
X
x
K
k
A
a
T
t
E
e
R
r
V
v
 
 
D
d
O
o
N
n
I
i
S
s
<
[
@
>
»
'
}
,
/
=
F
f
*
:
 
 
M
m
L
l
B
b
U
u
P
p
J
j

    Cost 1.97 per keystroke

Very Bad Keyboard

    H
    h
    V
    v
    X
    x
    J
    j
    Y
    y
    M
    m
     
     
    >
    '
    @
    «
    ?
    "
    Q
    q
    ]
    ^
    F
    f
    =
    }
    A
    a
    T
    t
    E
    e
    R
    r
    &
    *
     
     
    |
    `
    O
    o
    N
    n
    I
    i
    S
    s
    :
    -
    P
    p
    W
    w
    Z
    z
    K
    k
    B
    b
    G
    g
     
     
    +
    #
    <
    \
    {
    $
    [
    !
    ~
    %
    ,
    _

    Cost 3.04 per keystroke

Programmer's Keyboard

    K
    k
    D
    d
    <
    (
    >
    )
    :
    ;
    `
    »
      '
    «
    L
    l
    U
    u
    P
    p
    M
    m
    B
    b
    G
    g
    A
    a
    T
    t
    E
    e
    R
    r
    C
    c
      H
    h
    O
    o
    N
    n
    I
    i
    S
    s
    V
    v
    W
    w
    Y
    y
    F
    f
    [
    {
    ]
    }
    "
    /
      _
    \
    -
    =
    *
    +
    |
    ,
    ?
    .
    X
    x

    Cost 2.07 per keystroke

Conclusion