Karabiner: how to prevent Shift+Alt from being sent?

0

0

Can Karabiner's JSON configuration indicate that Shift+Alt should not be sent when typing Shift+Alt+other_key?

The use case is as follows, from inside Microsoft Remote Desktop connected to Windows:

  • Let's say I want to type Shift+Alt+) and insert "]" in the Windows app (as is usual with the French keyboard).
  • Now, when I start by typing Shift+Alt, Windows switches keyboard layouts. I want to keep this feature on the remote machine, but it should not interfere with Shift+Alt+other_key combinations.

Thus, I would like to produce "]" on the Windows remote machine when I type Shift+Alt+), without Shift+Alt switching between keyboard layouts.

It is not obvious that this could work, as Shift+Alt must be pressed first, which might necessarily trigger the keyboard layout switching. However, things could in principle work if Karabiner would not send anything to Windows when Shift+Alt is pressed, and then only send either "]" if ")" is pressed, or activate the layout switching when Shift+Alt is released.

My current configuration for having Shift+Alt+) produce "]" in Microsoft Remote Desktop (from a French-keyboard MacBook) is:

{
    "conditions": [
        {
            "bundle_identifiers": [
                "com\\.microsoft\\.rdc\\.(mac|osx|macos)"
            ],
            "type": "frontmost_application_if"
        }
    ],
    "from": {
        "key_code": "hyphen",
        "modifiers": {
            "mandatory": [
                "option",
                "shift"
            ]
        }
    },
    "to": [
        {
            "key_code": "close_bracket"
        }
    ],
    "type": "basic"
}

Eric O Lebigot

Posted 2019-10-09T19:10:28.067

Reputation: 124

Answers

0

In pure Windows, Shift+Alt by itself does nothing as long as you keep pressing both keys. It will only take effect when the keys are freed. Therefore I find it hard to understand why you have an immediate action when you only press the keys (but then I'm not on the Mac).

A possible solution would be to use on Windows the keyboard remapper AutoHotkey.

The following AutoHotkey script might block Shift+Alt by itself, but will convert Shift+Alt+( to ]. It worked for me on English Windows 10, and should also work in your environment.

!Shift::return
!+):: Send, ]

It might be worth testing if the script can work without the last line.

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

AutoHotkey references:

harrymc

Posted 2019-10-09T19:10:28.067

Reputation: 306 093

Note that your mappings in Karabiner might conflict with the above. – harrymc – 2019-11-27T10:02:04.967

Interesting, about Shift-Alt working upon release on Windows. I'm guessing that Karabiner someho does send the key releases instead of sending the release of the bracket only? Unfortunately I cannot install AutoHotKey on the remote PC, as it is administered by the IT department. – Eric O Lebigot – 2019-11-28T16:28:52.063

AutoHotKey has a portable version without installation. – harrymc – 2019-11-28T16:37:09.033

That's good. However, I use Shift-Alt constantly on the Windows machine, so I cannot deactivate it. If I remember correctly, another option is to ask Windows 7 for a different keyboard-switching key combo, but then other people will be surprised when they use my machine. That's why I was hoping that Karabiner could somehow handle this. – Eric O Lebigot – 2019-12-01T12:58:53.583

Using AutoHotKey, another possibility would be to assign another shortcut for switching languages. – harrymc – 2019-12-01T13:59:07.720

It’s built in Windows 7 already (Control Panel > Change Keyboard… > Change Keyboard > Advanced Key Settings). – Eric O Lebigot – 2019-12-02T14:36:43.457

Would you consider this as s solution to the problem? – harrymc – 2019-12-02T14:39:39.233

Unfortunately not, because this would be misleading for readers, as the question is really about "how to prevent Shift+Alt from being sent" by the Mac while "keeping [Shift+Alt for switching between keyboards] on the [Windows] machine"… – Eric O Lebigot – 2019-12-02T20:51:08.870

The post can be modified. The question is whether this helps you. – harrymc – 2019-12-02T20:53:05.520

It does in the sense that I now wonder whether the initial question does have an answer, and it doesn't in that I already had a simpler solution than what this answer proposes (see my comment above on the solution built in Windows 7). – Eric O Lebigot – 2019-12-02T20:57:33.610

"Change Keyboard" seems to be some application that is installed on your computer. The standard way is Control Panel > Region and Language > Keyboards and Languages > Change keyboards... > Advanced Key Settings > Between input languages > Change Key Sequence... – harrymc – 2019-12-02T21:12:16.493