MacOS – Control not working in iTerm 2 when using Programmer Dvorak keyboard layout

dvorakitermkeyboardmacos

I'm using the Programmer Dvorak keyboard layout and found that the Control key does not work in iTerm 2. Emacs is unusable as a result, and I can't interrupt processes with Ctrl-C. Interestingly, the only thing I have found control to do is that Ctrl-Z still sends SIGTSTP.

I've swapped the Ctrl and Caps-Lock keys at the Mac level, but undoing that has no effect. I use zsh, but running bash doesn't help. Everything works fine in Terminal.

How can I get a working control key?

PS: Reverting back to QWERTY does fix this, but that's not really an option.

Best Answer

Edit: There is now a new version of Programmer Dvorak that works with key combinations like ⌃A, so the instructions below are no longer needed.

◊ Option modifier is currently non-functional. Also, you cannot replace a default Roman layout with this one. Control keys should now be functional.

Option worked everywhere I tested, so non-functional could just mean that states under option don't output non-ASCII characters. If you want to disable all other input sources, you can edit the HIToolBox plist.

Instructions for older versions of Programmer Dvorak:

  1. Open /Library/Keyboard Layouts/Programmer Dvorak.bundle/Contents/Resources/Programmer Dvorak.keylayout
  2. And add this to modifierMap:

    <keyMapSelect mapIndex="3">
      <modifier keys="control anyOption? anyShift?"/>
    </keyMapSelect>
    
  3. Add this to keyMapSet:

    <keyMap index="3">
      <key code="0" output="&#x0000;"/>
      <key code="1" output="&#x0000;"/>
      <key code="2" output="&#x0000;"/>
      <key code="3" output="&#x0000;"/>
      <key code="4" output="&#x0000;"/>
      <key code="5" output="&#x0000;"/>
      <key code="6" output="&#x0000;"/>
      <key code="7" output="&#x0000;"/>
      <key code="8" output="&#x0000;"/>
      <key code="9" output="&#x0000;"/>
      <key code="10" output="&#x0000;"/>
      <key code="11" output="&#x0000;"/>
      <key code="12" output="&#x0000;"/>
      <key code="13" output="&#x0000;"/>
      <key code="14" output="&#x0000;"/>
      <key code="15" output="&#x0000;"/>
      <key code="16" output="&#x0000;"/>
      <key code="17" output="&#x0000;"/>
      <key code="18" output="&#x0000;"/>
      <key code="19" output="&#x0000;"/>
      <key code="20" output="&#x0000;"/>
      <key code="21" output="&#x0000;"/>
      <key code="22" output="&#x0000;"/>
      <key code="23" output="&#x0000;"/>
      <key code="24" output="&#x0000;"/>
      <key code="25" output="&#x0000;"/>
      <key code="26" output="&#x0000;"/>
      <key code="27" output="&#x0000;"/>
      <key code="28" output="&#x0000;"/>
      <key code="29" output="&#x0000;"/>
      <key code="30" output="&#x0000;"/>
      <key code="31" output="&#x0000;"/>
      <key code="32" output="&#x0000;"/>
      <key code="33" output="&#x0000;"/>
      <key code="34" output="&#x0000;"/>
      <key code="35" output="&#x0000;"/>
      <key code="36" output="&#x0000;"/>
      <key code="37" output="&#x0000;"/>
      <key code="38" output="&#x0000;"/>
      <key code="39" output="&#x0000;"/>
      <key code="40" output="&#x0000;"/>
      <key code="41" output="&#x0000;"/>
      <key code="42" output="&#x0000;"/>
      <key code="43" output="&#x0000;"/>
      <key code="44" output="&#x0000;"/>
      <key code="45" output="&#x0000;"/>
      <key code="46" output="&#x0000;"/>
      <key code="47" output="&#x0000;"/>
      <key code="48" output="&#x0000;"/>
      <key code="49" output="&#x0000;"/>
      <key code="50" output="&#x0000;"/>
      <key code="51" output="&#x0000;"/>
      <key code="52" output="&#x0000;"/>
      <key code="53" output="&#x0000;"/>
      <key code="64" output="&#x0000;"/>
      <key code="65" output="&#x0000;"/>
      <key code="66" output="&#x0000;"/>
      <key code="67" output="&#x0000;"/>
      <key code="69" output="&#x0000;"/>
      <key code="70" output="&#x0000;"/>
      <key code="71" output="&#x0000;"/>
      <key code="72" output="&#x0000;"/>
      <key code="75" output="&#x0000;"/>
      <key code="76" output="&#x0000;"/>
      <key code="77" output="&#x0000;"/>
      <key code="78" output="&#x0000;"/>
      <key code="79" output="&#x0000;"/>
      <key code="80" output="&#x0000;"/>
      <key code="81" output="&#x0000;"/>
      <key code="82" output="&#x0000;"/>
      <key code="83" output="&#x0000;"/>
      <key code="84" output="&#x0000;"/>
      <key code="85" output="&#x0000;"/>
      <key code="86" output="&#x0000;"/>
      <key code="87" output="&#x0000;"/>
      <key code="88" output="&#x0000;"/>
      <key code="89" output="&#x0000;"/>
      <key code="91" output="&#x0000;"/>
      <key code="92" output="&#x0000;"/>
      <key code="96" output="&#x0000;"/>
      <key code="97" output="&#x0000;"/>
      <key code="98" output="&#x0000;"/>
      <key code="99" output="&#x0000;"/>
      <key code="100" output="&#x0000;"/>
      <key code="101" output="&#x0000;"/>
      <key code="102" output="&#x0000;"/>
      <key code="103" output="&#x0000;"/>
      <key code="104" output="&#x0000;"/>
      <key code="105" output="&#x0000;"/>
      <key code="106" output="&#x0000;"/>
      <key code="107" output="&#x0000;"/>
      <key code="108" output="&#x0000;"/>
      <key code="109" output="&#x0000;"/>
      <key code="110" output="&#x0000;"/>
      <key code="111" output="&#x0000;"/>
      <key code="112" output="&#x0000;"/>
      <key code="113" output="&#x0000;"/>
      <key code="114" output="&#x0000;"/>
      <key code="115" output="&#x0000;"/>
      <key code="116" output="&#x0000;"/>
      <key code="117" output="&#x0000;"/>
      <key code="118" output="&#x0000;"/>
      <key code="119" output="&#x0000;"/>
      <key code="120" output="&#x0000;"/>
      <key code="121" output="&#x0000;"/>
      <key code="122" output="&#x0000;"/>
      <key code="123" output="&#x0000;"/>
      <key code="124" output="&#x0000;"/>
      <key code="125" output="&#x0000;"/>
      <key code="126" output="&#x0000;"/>
    </keyMap>
    
  4. Run sudo touch /Library/Keyboard\ Layouts/ and log out and back in