• You are not logged in.

    Tip for programmers

    • Started by tomlu
    • 15 Replies:
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192

    A lot of people seem to have tried new keyboard layouts and found them great for English text, but been disappointed to find that there is not a commensurate improvement when programming. I wanted to share what has worked for me in this regard.

    When touch typing I find I really like to stay at the home row. I have remapped the AltGr part of the keyboard to the keys I use the most often when programming. To find the best remapping I wrote a genetic algorithm and fed it a corpus of my earlier work. In my case, this was mostly C++ and Python code. I took the output of that as my starting point and then used intuition and experimentation to find what works best for me. This is my result (I have left a few spots clear for future expansion):

    \{}& |*[]
    #:;/0 1=()_
      !-+  23<>4

    If you are a Kinesis user, you can map a foot pedal to AltGr. I find this has really made programming easier for me.

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    Ah, interesting.

    \ { } &     | * [ ]
    # : ; / 0   1 = ( ) _
    ! - + 2       3 < > 4

    Is this what you mean? You didn't specify which keys you meant are the 'future expansion' ones?

    If I got it right: I like the way the bracket stuff all fell in line - including the '+-' (and I hope, '<>' and ';:' as well - hence my interpretation of your left-out keys).

    I suppose your line endings is the reason you mapped the semicolon towards the center with respect to the colon? However, I'm unsure whether it's a good idea to reverse the sequence from the comma-dot on the normal board. I think that I'd just map the colon and semicolon to where you put the <> for reasons of mnemonics and simplicity, even if that means having to reach a little more away from the home row.

    The numbers are another matter. Do you need AltGr mappings for them, really? Isn't AltGr plus a key just as much hassle as reaching to the top row for a number - even with a pedal?

    You could probably make the positions of the 'math' symbols such as '!' more intuitive, for instance placing the '!' on the Q key under the number 1 key where the '!' normally resides. (Then again, that's fairly easy to reach up there as well - certainly no worse than reaching the '$' sign which is also important for programming.)

    And as far as I can see, you're missing the programming-important caret (^) and grave (`) symbols. You may be too locked up in your two languages to see what other languages need, if you're trying to make something useful for other people too. I imagine it'd be useful to don the shoes of someone using, say, Perl, AutoHotKey and Visual Basic.

    Afterthought: How about you tell us what you found from your corpus? I mean, what were the different symbol frequencies?

    Last edited by DreymaR (27-Mar-2008 21:10:20)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192

    This is the precise layout:

    \ { } &     | * [ ]
    # : ; / 0   1 = ( ) _
      ! - +     2 3 < > 4
    DreymaR said:

    I suppose your line endings is the reason you mapped the semicolon towards the center with respect to the colon? However, I'm unsure whether it's a good idea to reverse the sequence from the comma-dot on the normal board. I think that I'd just map the colon and semicolon to where you put the <> for reasons of mnemonics and simplicity, even if that means having to reach a little more away from the home row.

    I put them there since they are frequently used.

    DreymaR said:

    The numbers are another matter. Do you need AltGr mappings for them, really? Isn't AltGr plus a key just as much hassle as reaching to the top row for a number - even with a pedal?

    I personally do not think so. I use them a lot, especially 0, 1 and 3.

    DreymaR said:

    And as far as I can see, you're missing the programming-important caret (^) and grave (`) symbols. You may be too locked up in your two languages to see what other languages need, if you're trying to make something useful for other people too. I imagine it'd be useful to don the shoes of someone using, say, Perl, AutoHotKey and Visual Basic.

    True. One of the free slots could be used for those.

    DreymaR said:

    Afterthought: How about you tell us what you found from your corpus? I mean, what were the different symbol frequencies?

    Here's a printout. Excuse the lack of formatting. Normalised to the most common character.

    [('/', 1.0), (')', 0.23), ('(', 0.23), (';', 0.18), ('=', 0.13), (':', 0.13), ('_', 0.11), ('-', 0.09), ('*', 0.09), ('{', 0.08), ('}', 0.08), ('1', 0.08), ('0', 0.08), ('>', 0.07), ('[', 0.06), (']', 0.06), ('#', 0.06), ('&', 0.05), ('2', 0.05), ('<', 0.05), ('"', 0.04), ('3', 0.04), ('!', 0.04), ('+', 0.03), ('4', 0.01), ('|', 0.0)]

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    Hmmm. From your data, it seems that only the slash, parentheses and ;=:_ or so really deserve special attention as the rest must be extremely rare in the whole picture. I don't think that frequencies in that extremely low range you're talking about here have any real impact on speed or general comfort whatsoever, so you should probably focus on ease of learning and remembering when choosing positions.

    On my Norwegian layout, I reach all those with a simple Shift-press and the underscore already has a reachable AltGr mapping. The {} and <> are more annoying to reach on my layout, and the /|\ chars are spread out making them a bit confusing.

    It's nice if you find this useful, but I'm uncertain about the general utility of it. The most appealing thing about it from my point of view, is the intuitive ordering of the various brackets. Since I already have easy access to ;: at the lower right (shift-period and shift-comma), I might want something like:

    ! " # $ &   . . [ ] .
    ` { } * -   . . ( ) .
    | \ / = +   . . < > _

    A few chars should be easy to remember there: Note how the /*-+ form the familiar NumPad sequence (and = nearby), and the !#$& chars are placed right beneath where I'd normally find them with Shift (if not stretching to the upper row really is important enough to have them here).

    I can't think of anything I'd really want to fill in the dots with; the 3x2 vacant block could have numbers I suppose - although it'd be even nicer if the numbers 123 and 456 could be placed NumPad-style under 789. In that case, I'd also place /*-+= to the right of those keys as they are on the NumPad. But then the neat bracket system is broken! Hmmm...

    ! [ ] $ &     4 5 6 -
    ` ( ) # \   / 1 2 3 +
    | { } < >     0   = _

    Just toying around with thoughts.

    Last edited by DreymaR (28-Mar-2008 11:05:38)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192
    DreymaR said:

    Hmmm. From your data, it seems that only the slash, parentheses and ;=:_ or so really deserve special attention as the rest must be extremely rare in the whole picture. I don't think that frequencies in that extremely low range you're talking about here have any real impact on speed or general comfort whatsoever, so you should probably focus on ease of learning and remembering when choosing positions.

    They are not that rare.  Given that there is almost a semicolon per line, the others are probably in the frequency range of one every four lines (if you squint and do a lot of hand waving). Combined, there will be a couple of them per line. I can't hit shift-number combinations without looking down, so if you neglect them that's almost two times looking at the keyboard per line of code. Personally, I don't like that.

    I optimised the layout quite carefully. I found that small changes often interacted in unexpected ways. Hence, I don't recommend changing things willy-nilly without running it through an optimiser or, even better, trying it out empirically for yourself. Having said that, I do recommend everyone to modify it to their heart's content since my way will probably not be best for you.

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    Ah yes, I do agree that it can be hard to hit keys up on that top row. I took a little training round on that today, actually. I guess it'll take a bit of workout to get it down to the point where I don't mistype the number keys at all.

    I still think that your careful optimisation may be quite unwarranted because every four lines of code isn't enough to make any kind of difference in the areas that optimisation is concerned with: Speed and comfort. So I'll reiterate my argument that for these rare(-ish) characters it's not about ergonomy but about intuitive and consistent placement. The best optimiser here will be your sense of symmetry and mnemonics. I'd think that given your results, anything past the slash, parentheses and semicolon should be placed not according to where it's easy to reach but where it's easy to remember to reach for it!

    That much being said, I suppose you still want to avoid same-finger digraphs. This would affect for instance several combinations like += -= >= in C languages. Seems to me the '=' should be for instance on the middle right-hand finger, and the others off that finger.

    You'll notice that my musings have touched upon this topic: https://forum.colemak.com/viewtopic.php?id=364  :)

    Last edited by DreymaR (28-Mar-2008 18:20:08)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 1
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192
    DreymaR said:

    I still think that your careful optimisation may be quite unwarranted because every four lines of code isn't enough to make any kind of difference in the areas that optimisation is concerned with: Speed and comfort. So I'll reiterate my argument that for these rare(-ish) characters it's not about ergonomy but about intuitive and consistent placement.

    I appreciate your input. However, I think you underestimate how often these characters are used. To exemplify: According to my data, several characters that you dub as rare (such as hyphen, *, curly braces and more) are actually more frequent than many English characters (such as w and j) and on par with many others. I feel that if you tried it I might be able to sway you to my way of thinking.

    DreymaR said:

    That much being said, I suppose you still want to avoid same-finger digraphs. This would affect for instance several combinations like += -= >= in C languages. Seems to me the '=' should be for instance on the middle right-hand finger, and the others off that finger.

    My optimiser respects this as well as several other parameters. You will for instance see that most characters likely to be preceded or followed by a carriage return are on the left hand side.

    Again, thanks for your input.

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    It's a well known factoid that many English characters such as w and j and many others don't need to be optimized on a keyboard layout but can safely be left where QWERTY dropped them for ease of remembrance, and that a Capewellian approach to these characters will only end in tears and/or neverending projects. Poor example on a Colemak forum, my friend.  ;D

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192

    Let's clarify: You do want to put all of these symbols somewhere on the alphabetic part of the keyboard? If yes, well, as long as you are a little careful you can probably optimise for ease of rememberance. If not, the exact point I am trying to make is: Would you be happy with these rare-ish characters (w, j) and others at shifted number positions?

    Offline
    • 0
    • Reputation: 0
    • Registered: 01-Apr-2008
    • Posts: 6

    Well, I don't have a pedal, and I just followed Programmer's Dvorak's example and created a custom Colemak layout where the top numbers are replaced by their symbols, in addition to exchanging -, [ and ] with their shift counterparts _, {, and } which are more commonly used in most programming languages.  You get - with numpad anyway.

    Not a lot easier, but I do not want Alt-Gr since I need all the Alt and Ctrl I have, with my IME and Code Whatever keyed to different sides.  I actually used to produce my own symbols layout where I replaced most of the symbols but I realised, after a few months, that it is not easier then doing min. position change and using your left Shift.

    If there are some way I can help with < and > I would like to, too.  Maybe I should hunt for a pedal after all...

    Last edited by Sheepy (02-Apr-2008 04:48:15)
    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192

    Sheepy: I tried that too but found it too uncomfortable for my hands to have to leave their home position all the time. If you touch type, I can really recommend getting a pedal.

    Offline
    • 0
    • Reputation: 23
    • From: Belgium
    • Registered: 26-Feb-2008
    • Posts: 480

    Sounds interesting...  How do such pedals work?  Are they seen by the O.S. as an additional USB-keyboard with only an AltGr key, or do they require special driver software?

    Last edited by ghen (03-Apr-2008 10:56:47)
    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Mar-2008
    • Posts: 192

    It varies. Mine are plugged straight into my Kinesis so they are part of the keyboard as far as the operating system is concerned. For a while I used a midi pedal and a custom written program that pressed altgr. That worked fine too albeit a bit less elegant. There are separate usb pedals that will work fine unless you are on a mac, for instance the kinesis savant ones.

    Offline
    • 0
    • Reputation: 23
    • From: Belgium
    • Registered: 26-Feb-2008
    • Posts: 480

    I found out about the Kinesis Savant pedals by now.  There exist several similar offerings on the web:

    http://www.kinesis-ergo.com/fs-savant-elite.htm
    http://www.pedalpeddler.com/Index.aspx?p=3
    http://www.pedalpax.com/SA1_Foot_Pedal.htm
    http://www.specialneedscomputers.ca/kb-footpedal.htm
    http://www.bilbo.com/

    These devices are recognized by the OS as regular USB keyboards (so they should work for me on NetBSD).  However you need a special (Windows-only) program to define the pedal actions, but that's just once.

    I would be interested in mapping Ctrl and Shift to a pedal, because I very regularly use such shortcuts and they can get painful after a while.

    The problem with Mac is apparantly that one keyboard's modifier keys (Shift, Ctrl, Alt, Option) can't modify another keyboard's input.  Other OS'es don't have this limitation.

    Offline
    • 1
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    There are several kinds on the market. I believe these or similar ones for the Kinesis keyboard are what's being talked about here:
    http://www.kinesis-ergo.com/fs-non-program.htm

    You can program them to emulate pretty much what you want. The Kinesis will let you use such pedals as a part of its' layout as I understand it, while non-Kinesis users will use pedals as a separate USB keyboard and/or mouse device (with a separate driver).

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 23
    • From: Belgium
    • Registered: 26-Feb-2008
    • Posts: 480
    Offline
    • 0