z4120's blog

By z4120, history, 3 years ago, In English

It's not uncommon for people here to try to improve their typing speed, or to complain that programming requires typing some hard-to-type characters frequently. There are a few solutions to that:

  • Buy an ergonomic keyboard model. May work, but will not be discussed here.
  • Just practice (on typeracer, etc.) This may help with the speed, but typing special symbol is still hard.
  • Use alternate keyboard layout: may not always be available in on-site programming contests. In particular, Programmer Dvorak layout is not available on Windows by default.
  • Key chording: discussed below.

While there are just so many keys on the keyboard, you can "make" more by chording the key (taking the idea from stenography). Then you can bind those to commonly typed keys/sequences.

  1. How to bind keys?

    Vim supports key binds natively. Just use noremap! (or just map!) I don't know if you don't use Vim.

  2. What key bindings do you use?

    ws = <bs>, uj = (, ik = ), UJ = [, IK = ], df = 0, un = unsigned, jp = .push_back(, jk = <<, as; = sa; = <esc>, fj = jf = <cr>, and some other ones.

  3. Isn't that a lot? Would it be very slow to type them during programming competitions?

    map! jp .push_back( is shorter than #define pb push_back. For brackets/special characters, it makes typing faster, so it's worth it.

  4. Would typing two/three keys be slower than one key?

    Typing shift+some key is not faster than typing two keys. Also, for key mappings that uses the same finger (such as uj or ik) you only need to press once. (I use some key cap to make it possible to press multiple keys with a single finger)

  5. Does this really matter? My typing speed is fast already.

    I think this is better ergonomically.

  6. What if I get the order of the key wrong?

    For chords typed with one finger that's not a problem. For others, a workaround is to use some plug-in (vim-arpeggio, for example) (not available in on-site contests), or to bind all permutations (not really feasible for combinations longer than 2 characters)

  7. Can they cause conflict with something else?

    It depends. Sometimes I get conflicts, but you can analyze your existing code to see if a combination is okay, or rename the variables (instead of rows you can use rowz for example)

  8. What about #define?

    Then you'll need to type parentheses anyway.

 
 
 
 
  • Vote: I like it
  • +10
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Have a look at these : Speed

Is this typing speed enough?

»
3 years ago, # |
  Vote: I like it +13 Vote: I do not like it

I think this is better ergonomically.

The research into ergonomicity of different layouts, models etc. is inconclusive. For every claim that X is better than Y, you have one that Y is better than X, with both supported by what you'd probably consider sound reasoning.

If you want to do something for your health, it's better to start lifting.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    However, it's obvious that with the typical 10-finger typing hand placement and Qwerty layout, pressing backspace is very difficult. You can't claim that something far away on a side of the keyboard is easier to press than something right under your finger.

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      It's not very difficult. Usually, if I press backspace, it's multiple times in a row (it's not like you have to immediately correct or even notice mistakes), so it is right under my finger, and it's not a key that's pressed too often, so optimising its use is inefficient anyway.

      • »
        »
        »
        »
        3 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Obviously it depends on the content being typed, and the typer, but for this person the backspace key is the second most frequent key typed. Also in the Colemak keyboard layout that key is moved to the position of caps lock (which is easier to reach)

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          That person has a problem that has nothing to do with keyboard layout. (Zero backspaces were harmed while typing this sentence.)

»
3 years ago, # |
Rev. 10   Vote: I like it 0 Vote: I do not like it

I'm not cool enough to use Vim (or Emacs for that matter), but this post inspired me to experiment with remapping the right-Alt key (or right-command key in Mac) to what I call "Programmer's AltGr", as regions with accented or other extra letters in their language (e.g. German, French) often replace that key with an "AltGr" key to type them. (Fitting, as our favorite computer language can feel like a second language sometimes!)

The prototype is below, green characters being what you get when you press right-alt with that key. The base keyboard is Dvorak because it's what I use normally. Please excuse the lousy image-editing :P

Old version

Additional notes:

  • AltGr + space = space, to make it easier to put space around symbols

  • AltGr + F intentionally left blank because it sucks to reach

Edit: Changed the number keys at the bottom row. After some experimentation I shifted 0,2,4,6 one space to the right, then put 8 where 0 was, since 0 is pretty common. Also mapped AltGr + equals to CapsLock (you may want to map backspace instead if you've not switched caps-lock / backspace like I did)

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Does this actually do anything in terms of effectiveness? Also, why are the numbers arranged so weird?

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 4   Vote: I like it +6 Vote: I do not like it

      Well it's not like I can produce any empirical studies or anything since I pretty much just invented it (though I don't claim all the credit; I've taken inspiration from various sources including the "Programmer's Dvorak" alternate layout). It's mostly something I made for myself that maybe some others might be interested in.

      The numbers are arranged as in the original Dvorak proposal for the number row (edit: used to be) — I've decided to try it that way because putting lower numbers near the middle is more optimized for Benford's Law, which is more important when typing them along with a bunch of symbols in my opinion (and apparently in the Programmer's Dvorak author's opinion too).