Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set right_shift = command+space? #19

Closed
jinjian1991 opened this issue Sep 16, 2016 · 9 comments
Closed

How to set right_shift = command+space? #19

jinjian1991 opened this issue Sep 16, 2016 · 9 comments
Labels

Comments

@jinjian1991
Copy link

How to set right_shift = command+space?

@talha131
Copy link
Contributor

You can't until #16 is fixed.

@oylbin
Copy link

oylbin commented Oct 8, 2016

keep on watching this.

@oylbin
Copy link

oylbin commented Oct 27, 2016

@jinjian1991

check this comment

@jerryjune
Copy link

jerryjune commented Dec 29, 2017

I guess you want to switch input source. But you cannot map shift to command space to do that. Following is an example to switch between sogou input and ABC keyboard. Pay attentation to the input_source_id is for keyboard layout and input_mode_id is for some input software(for example chinese sogou). You can get this information from ~/Library/Preferences/com.apple.HIToolbox.plist
This script is modfied on these two offical examples
example_input_source.json
example_select_input_source.json

{
    "description": "LeftShift to Switch Input Source",
    "manipulators": [
        {
            "conditions": [
                {
                    "type": "input_source_if",
                    "input_sources": [
                        {
                            "language": "en"
                        }
                    ]
                }
            ],
            "type": "basic",
            "from": {
                "key_code": "left_shift",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "left_shift"
                }
            ],
            "to_if_alone": [
                {
                    "select_input_source": {
                        "input_mode_id": "com.sogou.inputmethod.pinyin"
                    }
                }
            ]
        },
        {
            "conditions": [
                {
                    "type": "input_source_unless",
                    "input_sources": [
                        {
                            "language": "en"
                        }
                    ]
                }
            ],
            "type": "basic",
            "from": {
                "key_code": "left_shift",
                "modifiers": {
                    "optional": [
                        "any"
                    ]
                }
            },
            "to": [
                {
                    "key_code": "left_shift"
                }
            ],
            "to_if_alone": [
                {
                    "select_input_source": {
                        "input_source_id": "com.apple.keylayout.ABC"
                    }
                }
            ]
        }
    ]
}

@bao3
Copy link

bao3 commented Jan 1, 2018

Thanks @jerryjune , it's great . Now I could switch input source between RIME and apple.US .

@stale
Copy link

stale bot commented Mar 3, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 3, 2018
@stale stale bot closed this as completed Mar 10, 2018
@uhayate
Copy link

uhayate commented Sep 7, 2018

@jerryjune it's great.

@oylbin
Copy link

oylbin commented Sep 20, 2018

Thanks @jerryjune .
I struggled for an hour and finally found the slightly difference between input_source_id and input_mode_id 😭

I will list my config below in case it can help someone use ”U.S.“ and "Pinyin - Simplified" like me:

    {
        "description": "LeftShift to Switch Input Source",
        "manipulators": [
            {
                "conditions": [
                    {
                        "input_sources": [
                            {
                                "input_source_id": "com.apple.keylayout.US"
                            }
                        ],
                        "type": "input_source_unless"
                    }
                ],
                "from": {
                    "key_code": "left_shift",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "left_shift"
                    }
                ],
                "to_if_alone": [
                    {
                        "select_input_source": {
                            "input_source_id": "com.apple.keylayout.US"
                        }
                    }
                ],
                "type": "basic"
            },
            {
                "conditions": [
                    {
                        "input_sources": [
                            {
                                "input_mode_id": "com.apple.inputmethod.SCIM.ITABC"
                            }
                        ],
                        "type": "input_source_unless"
                    }
                ],
                "from": {
                    "key_code": "left_shift",
                    "modifiers": {
                        "optional": [
                            "any"
                        ]
                    }
                },
                "to": [
                    {
                        "key_code": "left_shift"
                    }
                ],
                "to_if_alone": [
                    {
                        "select_input_source": {
                            "input_mode_id": "com.apple.inputmethod.SCIM.ITABC"
                        }
                    }
                ],
                "type": "basic"
            }
        ]
    }

zetavg added a commit to zetavg/dotfiles that referenced this issue Jul 31, 2019
@SYKoh
Copy link

SYKoh commented Jan 20, 2022

@oylbin oh my gosh, I almost cry

before I met this issue page, I was confused by the ramdom switch of input method using ctrl+space

by following your script, I improved my script, and now it works sooo good

my script behavies: switch input method when press capslock alone, held ctrl when capslock held down

{
    "title": "",
    "rules": [
        {
            "description": "switch input method when press capslock alone, held ctrl when capslock held down",
            "manipulators": [
                {
                    "conditions": [
                        {
                            "input_sources": [
                                {
                                    "input_source_id": "com.apple.keylayout.ABC"
                                }
                            ],
                            "type": "input_source_unless"
                        }  
                    ],
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock"
                    },
                    "to": [
                        {
                            "key_code": "left_control",
                            "lazy": true
                        }
                    ],
                    "to_if_alone": [
                        {
                            "select_input_source": {
                                "input_source_id": "com.apple.keylayout.ABC"
                            }
                        }
                    ]
                },
                {
                    "conditions": [
                        {
                            "input_sources": [
                                {
                                    "input_source_id": "com.apple.inputmethod.SCIM.ITABC"
                                }
                            ],
                            "type": "input_source_unless"
                        }  
                    ],
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock"
                    },
                    "to": [
                        {
                            "key_code": "left_control",
                            "lazy": true
                        }
                    ],
                    "to_if_alone": [
                        {
                            "select_input_source": {
                                "input_source_id": "com.apple.inputmethod.SCIM.ITABC"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

and from the official doc I learned that you can found your input method now in Karabiner EventViewer
investigate-the-input-source-identifiers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants