pqrs-org / Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
https://pqrs.org/osx/karabiner/
The Unlicense
3.82k stars 309 forks source link

How to map option + a to á on an US English keyboard #896

Closed gui-ben closed 4 years ago

gui-ben commented 4 years ago

Hi!

I'm trying to create a rule that does the following (on a US keyboard):

As I'm a newbie, I started writing a simple rule for the first case (letter a) and the left option key:

{
            "description": "left option + a = á",
            "manipulators": [
                {
                    "type": "basic",
                    "conditions": [
                        {
                            "type": "input_source_if",
                            "input_sources": [
                                {
                                    "input_source_id": "com.apple.keylayout.US"
                                }
                            ]
                        }
                    ],
                    "from": {
                        "key_code": "a",
                        "modifiers": {
                            "mandatory": [
                                "left_alt"
                            ]
                        }
                    },
                    "to": [
                        {
                            "select_input_source": {
                                "input_source_id": "com.apple.keylayout.Spanish"
                            }
                        }
                    ],
                    "to_after_key_up": [
                        {
                            "key_code": "a",
                            "modifiers": {
                            "mandatory": [ "open_bracket" ]
                            }
                        },
                        {
                            "select_input_source": {
                                "input_source_id": "com.apple.keylayout.US"
                            }
                        }
                    ]
                }
            ]
        }

The logic that I tried to reflect on this rule is the following:

If the keyboard is US, and 'left_option' + 'a' is pressed, change the keyboard to Spanish and press '[' and 'a', which is how the 'á' is created on a Spanish keyboard (I tried first with just writing 'á' on the key_code field but it didn't work).

But this rule is not working, the outcome I'm getting is 'å', which is the standard outcome for pressing the option key + 'a' on an English US keyboard.

Can someone help me writing this rule? Thanks!!

gui-ben commented 4 years ago

Solved it: https://github.com/ingmrb/dotfiles/blob/master/karabiner_elements_rules.json