OS X Terminal: Meta key + alt functionality at the same time

后端 未结 16 1563
不知归路
不知归路 2020-12-22 22:38

Is there a way to use an alt / option key as a meta key but still be able to use it to make some characters which need it?

For example, in my l

16条回答
  •  没有蜡笔的小新
    2020-12-22 23:03

    Special keyboard layout with option deadkey

    My solution to this problem is a special keyboard layout I have written, U.S. custom. It provides an option deadkey that produces option combos without having to use the physical ⌥ Option modifier key. For instance, the character ⟨ç⟩ is produced as follows on a normal U.S. keyboard layout:

    • Hit ⌥ Option+c.

    The U.S. custom keyboard layout adds a second way of producing ⟨ç⟩:

    • Hit ⇧ Shift+§ (the option deadkey), then release it, then hit c.

    This works even in Terminal.app when Use option as meta key has been checked.

    Note that the U.S. custom keyboard layout does two additional things:

    1. It converts plain § into a ⎄ Compose key (so you could also produce ⟨ç⟩ by hitting §, then ,, then c).
    2. It replaces the CapsLock mapping by a (significantly extended) U.S. Extended keyboard layout.

    Remap option deadkey to right option modifier key

    If you have a physical ANSI keyboard, then you lack the § key. In that case, I recommend assigning the § key to some other key, for instance to the right ⌥ Option modifier key. Install KeyRemap4MacBook, open ~/Library/Application\ Support/KeyRemap4MacBook/private.xml and paste the following code:

    
    
    
      Send ISO Section for right Option
      private.send_iso_section_for_right_option
      --KeyToKey-- KeyCode::OPTION_R, KeyCode::UK_SECTION
    
    
      Send Shift+ISO Section for Shift+right Option (keep normal right Option without Shift)
      private.send_shift_iso_section_for_shift_right_option
      --KeyToKey-- KeyCode::OPTION_R, ModifierFlag::SHIFT_R, KeyCode::UK_SECTION, ModifierFlag::SHIFT_L
      --KeyToKey-- KeyCode::OPTION_R, ModifierFlag::SHIFT_L, KeyCode::UK_SECTION, ModifierFlag::SHIFT_L
    
    
    

    Then, open the KeyRemap4MacBook preference pane, hit ReloadXML and then select “Send ISO Section for right option”. Now, your ⌥ Right Option key is remapped to §, so while the U.S. custom keyboard layout is active, hitting ⇧ Shift+⌥ Right Option will give you the option deadkey state (hitting ⌥ Right Option without additional modifiers will give you a deadkey state equivalent to the option modifier.

    If want to keep ⌥ Right Option when ⇧ Shift is not pressed (instead of the ⎄ Compose key), then select “Send Shift+ISO Section for Shift+right Option (keep normal right Option without Shift)” in the KeyRemap4MacBook preference pane (instead of “Send ISO Section for right Option”). Like that, only ⇧ Shift+⌥ Right Option will produce the option deadkey, while plain ⌥ Right Option will continue to work as an option modifier. You can even continue using ⌥ Right Option+⇧ Shift modifier combos (for instance ⌥ Right Option+⇧ Shift+c→⟨Ç⟩) as long as you don’t hit ⇧ Shift first.

提交回复
热议问题