PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[KBM] Right Alt Gr key stopped working after switching left Ctrl/Alt keys

Open micc83 opened this issue 4 years ago • 17 comments

Environment

Windows build number: Microsoft Windows [Versione 10.0.18363.836]
PowerToys version: v0.18.0
PowerToy module for which you are reporting the bug: Keyboard Manager

Steps to reproduce

    • Map key Ctrl (left) to Alt (left)
    • Map key Alt (left) to Ctrl (left)
    • Press Alt Gr (Right Alt Key) + Any key (for example @ on Italian Keyboard )

Actual VS Expected behavior

Before the remapping Alt Gr + @ works and output a @ while after the remapping the Right Alt key behaves like a regular Alt Key so the output is ò. I've even tried to remap Alt (right) + ò to Alt (Right)+Ctrl (Right)+ò but still not working.

micc83 avatar May 22 '20 06:05 micc83

Possibly related to #3641.

arntj avatar May 24 '20 09:05 arntj

I had the exact same issue when doing exactly the same remap. Updating to v0.18.1 doesn't fix it.

You don't even have to remap any of the Alt keys for PowerToys to break Alt Gr. If you try to just remap Win (Left) to Ctrl (Left) and Ctrl (Left) to Win (Left) then Alt Gr still breaks and you lose the ability to write @ on many international keyboard layouts (along with {. }, [, ] and many more)

If you however only remap Caps Lock, then the Alt Gr is fine and still works.

baldurbjarnason avatar May 24 '20 21:05 baldurbjarnason

After digging more into this, it turns out Alt Gr is internally just Ctrl (Left) + Alt (Right) at the virtual key level. When using English US keyboard Alt Gr behaves like a normal Alt (Right), but it changes for other languages. Which is why if you remap Ctrl (Left) it will affect Alt Gr as well. In order to support this particular use case we would have to look into scan code based remaps rather than virtual key code. @saahmedm what do you think about this issue?

arjunbalgovind avatar May 28 '20 18:05 arjunbalgovind

To verify that Alt Gr is actually Ctrl(Left) + Alt (Right) you can try this shortcut on Windows from this guide:

Ctrl + Alt + Tab Use the arrow keys to switch between all open apps.

If you are not using English-US you can invoke this either by Ctrl(L)+Alt(L)+Tab or AltGr+Tab

arjunbalgovind avatar May 28 '20 19:05 arjunbalgovind

Hello @arjunbalgovind,

Ctrl + Alt + Tab or AltGr +Tab (without remappings) are indeed working as expected (the tab navigation screen is shown and kept open). In the while I messed up a little. I forced a shortcut remapping with the Alt (left) + Alt (right) key, ignored the warning message about using the same key twice, and saved the configuration. Now the Keyboard Manager stops working every time I try to get into the remapping screens (both single keys and shortcuts), also remapping screens are not showing at all. How can I reset the Keyboard Manager configuration? As soon as I'll be able to reproduce the bug that brought me here I'll open a new ticket with all the steps to reproduce it.

micc83 avatar May 29 '20 06:05 micc83

@micc83 I wasn't able to repro this issue.

what happens when you try get to KBM? Does it crash? does it not open when you click?

saahmedm avatar Jun 03 '20 14:06 saahmedm

I'm not sure what happens under the hood. However, when I click on the shortcuts remapping button:

  • The remapping screen doesn't show up
  • The remapping module stops working all together
  • Powertoys Run keeps working
  • The Powertoys icon in the traybar disappears

micc83 avatar Jun 03 '20 15:06 micc83

Hello @arjunbalgovind,

Ctrl + Alt + Tab or AltGr +Tab (without remappings) are indeed working as expected (the tab navigation screen is shown and kept open). In the while I messed up a little. I forced a shortcut remapping with the Alt (left) + Alt (right) key, ignored the warning message about using the same key twice, and saved the configuration. Now the Keyboard Manager stops working every time I try to get into the remapping screens (both single keys and shortcuts), also remapping screens are not showing at all. How can I reset the Keyboard Manager configuration? As soon as I'll be able to reproduce the bug that brought me here I'll open a new ticket with all the steps to reproduce it.

You should be able to reset all your remappings as a quick workaround by deleting C:\Users\Username\AppData\Local\Microsoft\PowerToys\KeyboardManager. This will however delete any keyboard remappings you had saved earlier

arjunbalgovind avatar Jun 03 '20 15:06 arjunbalgovind

@micc83 before you delete that file, can you share a screenshot of the contents of the file? So that we can identify what configuration under the hood was actually causing the crash.

arjunbalgovind avatar Jun 03 '20 15:06 arjunbalgovind

Sure, I was already doint it 😄

Ps. Cool you're using json for storing configs... I was expecting some binary...

default.json

{
    "remapKeys": {
        "inProcess": [
            {
                "originalKeys": "20",
                "newRemapKeys": "162"
            },
            {
                "originalKeys": "164",
                "newRemapKeys": "162"
            },
            {
                "originalKeys": "162",
                "newRemapKeys": "164"
            }
        ]
    },
    "remapShortcuts": {
        "global": [
            {
                "originalKeys": "165;192",
                "newRemapKeys": "165;192"
            },
            {
                "originalKeys": "162;9",
                "newRemapKeys": "164;9"
            }
        ]
    }
}

micc83 avatar Jun 03 '20 15:06 micc83

I've reset first the remapShortcuts.global property, the error was still there. I then deleted remapKeys.inProcess and it started working back.

micc83 avatar Jun 03 '20 15:06 micc83

@micc83 Can you create a separate issue for the crash you were facing. It looks like there's definitely some bug, because even if you ignore the warnings, { "originalKeys": "165;192", "newRemapKeys": "165;192" }, shouldn't be possible. Edit: I was able to reproduce it by doing what you mentioned. It looks like PowerToys crashes.

arjunbalgovind avatar Jun 03 '20 22:06 arjunbalgovind

I read in #3641 that this issue will be considered in v1. For now this easy tweak can solve the issue. I, as a user who is used to the nice location of cmnd key in Mac OSX, wanted to switch Left-Ctrl and Left-Alt with PowerToys. And then, remap the shortcuts (Alt+Tab with Ctrl+Tab) and (Alt+F4 with Ctrl+Q), so that I get exactly the functionality similar to Mac OSX. But doing so, messes up the Right-Alt (Alt Gr) as well. This is a problem specially if your keyboard is not English, thus, you need Alt Gr to type certain characters. The solution was to change ONLY the left Ctrl and left Alt using the registry method (e.g. the method described here). And then, use PowerToys to change the above shortcuts (and not using the Remap functionality). Until a fix from PowerToys, this will resolve the issue.

archilious avatar Oct 13 '20 18:10 archilious

Any update on this?

Powertoys still can't distinguish AltGr from LCtrl. It wouldn't be such a pain if you could somehow set a shortcut for LCtrl + <key>, but leave LCtrl + RAlt + <key> as default, but without it, keyboard manager is literally unusable alongside keyboard layouts which use AltGr 😥.

Gieted avatar Mar 09 '21 19:03 Gieted

I used to swap ctrl and alt using Remapkey.exe and whatever method worked there doesn't with powertoys.

Sadly I cannot restore the behaviour with just remapping right alt to the key combo as it faults. Note that the physical key-press itself registers as LCtrl and RAlt when captured.

image

ievr avatar Nov 23 '21 19:11 ievr

Note that the physical key-press itself registers as LCtrl and RAlt when captured.

That's the cause of many issues. Most people just don't know that AltGr = (L)Ctrl + (R)Alt and many remap their (left) Ctrl keys...

Jay-o-Way avatar Nov 23 '21 22:11 Jay-o-Way

So, I cannot make this mapping work at all. When I attempt the mapping, even without mapping (L)Ctrl at all, I get told that "some keys cannot be mapped", and then that setting isn't saved. Can someone please advise what I could do? It's difficult to use my native language without any AltGr anywhere on the keyboard.

image image

EDIT: I ended up using SharpKeys instead, which solved the problem without any issues.

JoannaFalkowska avatar Dec 02 '21 12:12 JoannaFalkowska