An Ideal Keyboard Layout for Programming

78,084

Solution 1

I still hold that typing speed is not the main factor in the time it takes for a project to be completed. If it is, there is a big problem (Weeks of coding saves us hours of planning).

Regarding your question I prefer using the standard layout as it means I don't have to spend the first 10 minutes looking stupid when presented with a standard keyboard layout.

Some of the replacements you have suggested, e.g. the top row with the special characters doesn't make a ounce of difference as the outside finger on the other hand should be moving to shift at the same time.

IMHO One thing that helps above chaining layouts is using only keyboard shortcuts. Vim and Emacs are recommended. It makes moving text around far faster.

Solution 2

I would approach your question in the following way. The task is to organise a keyboard in such way as to minimise key strokes and hand movement for given text.

Steps toward a possible solution. Make a program that:

  1. Takes a text file with source code. (The bigger the better and from various sources!)
  2. Counts the frequency of use of each symbol (its presence in the text).
  3. (optional) Based on step 2: The program generates key stroke count for each symbol plus how far the hand has to go from central position. As a result you will have a measure how effective your keyboard layout is.

Now manually or by writing a program Redefine your layout in the following way. Put most frequently used symbol in a central position closer to your strong hand. The second symbol goes to your weak hand in central position. The third symbol goes back to your strong hand...and so on. Then you gradually move from central position of the hands into more "distant" areas of the keyboard. When all keyboard is full then you continue the process of assigning keys but this time with Shift key pressed. The other difference would be that you do not rotate strong and weak hand for each symbol when the Shift is down. With shift key down first you would fill in central positions on the keyboard and then move to more distant positions.

When you do all that perform step 3 again for the new layout to see how the layout was improved.

You may have to carry your keyboard with you at all times. On the bright side nobody will touch your computer. It will make you look like a Pro.

Finally, don't forget to share your findings.

Solution 3

I'm playing with a variant of the Colemak layout at the moment with heavy changes of symbols:

without SHIFT:

` - { } [ ] ; < > ( ) _ =
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 , . !

with SHIFT:

~ 1 2 3 4 5 6 7 8 9 0 & +
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 % : ?

Maybe I'll restore the / key...

But this is not based on any sound research, and I'd also love to see a layout optimized (Optimization including stuff like hand alteration etc, also ZXCV preservation, ...) with a sourcecode based corpus, because all these layouts seem to be optimized for prose only. For example, 'f' is a very common letter in C (if, for).

Update: I'm currently using

` - { } [ ] @ < > ( ) _ =
q w k r g y u l p * ; #
a s f t d h n e i o ' \
\ z x c v b j m , . /

with SHIFT:

~ 1 2 3 4 5 6 7 8 9 0 ^ +
Q W K R G Y U L P & ! $
A S F T D H N E I O " |
| Z X C V B J M % : ?

This is based on a 6-key-swap partial optimization taken from Carpalx with preservation of the usual Cut/Copy/Paste/Undo shortcuts and modified to give a better access to the usual programming characters.

Solution 4

Make a simple key logger, then count the number of times each key is pressed. Run it for a day or two, then save the output to a text file. Do this every once and a while. It doesn't matter what layout you are using, as you are just seeing which keys are being used the most.

If you want to make a good layout, you can't be afraid to go away from the norm. I'd suggest putting the top 11 keys along the home row, then the next top 11 keys as the top row (leave the 2 keys above the return key as the least used keys), then the 3rd top 11 keys as the bottom row. There should be 4 keys left over now. Take those and put them in the -= and ]\ slots. Congrats! You have now made a great keyboard layout for your purposes! =D

Share:
78,084
Jon Purdy
Author by

Jon Purdy

A programming language technologist

Updated on June 20, 2020

Comments

  • Jon Purdy
    Jon Purdy about 4 years

    I often hear complaints that programming languages that make heavy use of symbols for brevity, most notably C and C++ (I'm not going to touch APL), are difficult to type because they require frequent use of the shift key. A year or two ago, I got tired of it myself, downloaded Microsoft's Keyboard Layout Creator, made a few changes to my layout, and have not once looked back. The speed difference is astounding; with these few simple changes I am able to type C++ code around 30% faster, depending of course on how hairy it is; best of all, my typing speed in ordinary running text is not compromised.

    My questions are these: what alternate keyboard layouts have existed for programming, which have gained popularity, are any of them still in modern use, do you personally use any altered layout, and how can my layout be further optimised?

    I made the following changes to a standard QWERTY layout. (I don't use Dvorak, but there is a programmer Dvorak layout worth mentioning.)

    • Swap numbers with symbols in the top row, because long or repeated literal numbers are typically replaced with named constants;
    • Swap backquote with tilde, because backquotes are rare in many languages but destructors are common in C++;
    • Swap minus with underscore, because underscores are common in identifiers;
    • Swap curly braces with square brackets, because blocks are more common than subscripts; and
    • Swap double quote with single quote, because strings are more common than character literals.

    I suspect this last is probably going to be the most controversial, as it interferes the most with running text by requiring use of shift to type common contractions. This layout has significantly increased my typing speed in C++, C, Java, and Perl, and somewhat increased it in LISP and Python.

  • Jon Purdy
    Jon Purdy over 14 years
    Oh, no, typing speed isn't a bottleneck by any means, but at the same time, why let something as silly as a keyboard get in your way? I've had no trouble switching back and forth between my layout and others, because I use both frequently; I simply prefer mine. And I must admit, emacs makes programming fast as can be—when I don't have to look up a key sequence.
  • T.J. Crowder
    T.J. Crowder over 14 years
    I happily switch between two layouts. Jon reports it's been "a year or two" and he has no trouble going back and forth. YMMV, basically.
  • Jon Purdy
    Jon Purdy over 14 years
    Oh, and the simultaneity of left and right hand movements also doesn't make a difference: the modifier still has to be depressed before the key is struck. A difference of milliseconds, surely, but again, why hinder yourself? Programming with a layout that doesn't work for you is like programming on a sticky keyboard.
  • JesperE
    JesperE over 14 years
    I maintain that by keeping several keyboard layouts in memory you are sabotaging your muscle-memory and thereby making your typing slower.
  • Admin
    Admin over 14 years
    The other issue with the shift key is sequences where you are alternating, so both hands are jumping from the top row to their shift key and back. I'm not saying it's common enough to worry about, though, but things like "(!*x)" might qualify as irritating.
  • liori
    liori over 14 years
    I find changing between keyboards and keyboard layouts as easy/difficult as changing between speaking in different languages -- if you know them well, after few minutes you regain full speed of thought.
  • Jon Purdy
    Jon Purdy over 14 years
    @liori: well said, though whether it's on the order of minutes or seconds is entirely dependent on how tired I am. :P
  • Jason D
    Jason D over 14 years
    @liori "after a few minutes..." It seems that (multinational) companies and nations standardize on languages for a couple of purposes. 1) Speed of communication. 2) accuracy of communication. I suspect standardize keyboard layouts see similar benefits.
  • liori
    liori over 14 years
    @Jason D: Valid points, but I am glad they're not applicable to me... I rarely use other people's computers.
  • Jason D
    Jason D over 14 years
    @Liori. A good lot of companies have conference rooms with shared computers. And a good lot of developers will let someone else "drive" their computer when tag teaming a difficult issue. If others REFUSE to touch your computer due to your non-standard layout, you could be hampering cooperative problem solving. And for your employer, that eliminates the bulk of the personal benefits you reap with the chosen layout. Remember, development isn't usually one man against the world. It's usually done as a team.
  • liori
    liori over 14 years
    @Jason D: Oh, that's not a problem. Switching between keyboard layouts is as simple as clicking one button on screen... at least on my computer; especially that I still do use standard layout for games :-)
  • Evgeni Sergeev
    Evgeni Sergeev over 10 years
    -1: Doesn't contribute anything to the discussion (the "looking stupid" argument isn't backed up by even one datum from experience, it's a forward-looking worry) and can't be fixed.
  • Thumbz
    Thumbz about 10 years
    My wrists are starting to crack every time I reach for the curly braces... If you're just starting, I recommend looking into proper typing ergonomics, and also learning a Programming DVORAK. It's healthier, and you won't be getting arthritis at 23.
  • Ray
    Ray about 10 years
    I like the idea of making the characters default over the numbers. ie: shift+1 to get one, and pressing 1 gives you !
  • Hugues BR
    Hugues BR over 9 years
    i'm not really sure about the benefits of this answer...? it's not really a question about fastest development trick, but good layout for developer which can be about speed, ease or even just finger cramp...
  • Andrew Magerman
    Andrew Magerman about 9 years
    I agree. i even tried some dvorak and programmer's dvorak. The main issue is that your skills are not portable.
  • Michael Johnston
    Michael Johnston over 8 years
    it's not the speed it's the mental drag.
  • Julien__
    Julien__ over 8 years
    Very good answer: keyboard should be taylored to owner
  • Mihai MATEI
    Mihai MATEI about 8 years
    For keyboard usage statistics, there are already good programs that can show a heatmap, like this one: WhatPulse
  • WesternGun
    WesternGun about 7 years
    -1. I don't change my keyboard layout to speed up my typing. I just think the current QWERTY is only for English, and I want to be able to type three languages and their punctuations and special characters, in the meanwhile, programming, without switching keyboard layout. So I maintained my letters keys same as QWERTY, but changed the symbol keys.
  • Noah Krasser
    Noah Krasser over 6 years
    Actually I think that would be a pretty funny situation, if you type with the speed of a small-child, they ask you "nah, not a tech-guy huh?" and you tell them you actually are a programmer. I want to see that face :D
  • Tgwizman
    Tgwizman about 6 years
    [Visiting old post comments] That is actually a really cool (or heated ;]) idea. I'll have to check into that myself!
  • pjincz
    pjincz about 4 years
    I really like this answer, :P
  • awe lotta
    awe lotta over 3 years
    If one wanted to make things more complicated, one could factor in character combinations and try to make the hands alternate or avoid same-finger strokes (like "kilo" on QWERTY)
  • Kani
    Kani about 3 years
    Would change the source code text file to a keylogger to get also shortcuts you press and optimize them.