microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.79k stars 6.58k forks source link

Mapping Alt+Left to MediaNext also remaps all other meta-key combinations #10961

Open mrshanepaul opened 3 years ago

mrshanepaul commented 3 years ago

Microsoft PowerToys version

0.35.0

Running as admin

Area(s) with issue?

Keyboard Manager

Steps to reproduce

Remap a shortcut: Alt(Left) + Left -> Next Tack

Press: Ctrl+Alt+Left OR: Ctrl+Shift+Alt+left OR: Shift+Alt+left

✔️ Expected Behavior

For the shortcut to be restricted to the combination entered.

❌ Actual Behavior

It fires the media event no matter what. Even if that key combination is used locally in the application I am using.

Other Software

Spotify

enricogior commented 3 years ago

@mrshanepaul can you please post a screenshot of your mapping? Thanks.

mykhailopylyp commented 3 years ago

@mrshanepaul It is by design. We map exact match only for shortcut to shortcut remapping.

Regarding, Even if that key combination is used locally in the application I am using., we have two types of shortcut remapping global and app-specific so you can specify an app. I guess for music switching it is better when It is global.

mrshanepaul commented 3 years ago

@enricogior I do not have an advanced setup up, it is just a basic rebind. Here is the image as requested. image

@mykhailopylyp You have it backwards, that IS the functionality I want. It is doing the opposite. :)

I wrote a key remapping/window management app myself a few years ago (it could recognise individual USB devices and use separate remaps for each - surprisingly difficult in windows) in C# and your tool made mine mostly obsolete. :)

I realise that key combinations in windows do not all work the same way, especially when it comes to meta and special keys.

It might be something to do with this.

crutkas commented 3 years ago

So using my keyboard with a Next Track, Spotify only response to the key if Spotify (mine is installed via Store) is in focus. Both normal "Next Track" key and a remapped key. If i flip over to Media Player, both real key and the remapping works appropriately. Tried with both PT running and not running.

So this is spotify not respecting the actual 'next track' event. Repro'ed as external.

here was my remap image

mrshanepaul commented 3 years ago

@crutkas

You are mistaken. That is not my issue at all.

Spotify control works perfectly on my machine.

The issue I am having is that it is being controlled when I use OTHER metakeys in addition to the Alt key.

As per the bug report:

When I Press: Ctrl+Alt+Left OR: Ctrl+Shift+Alt+left OR: Shift+Alt+left

I am pretty sure this has nothing to do with Spotify.

crutkas commented 3 years ago

Sorry, i misread the setup step.

crutkas commented 3 years ago

Notes:

  1. I can repro this on 1 machine but not another. the one i can is a Windows Insider build 21359
    1. the one i was in middle of an OS upgrade cycle.
  2. One i can't is having Alt+Left act like it can't be overridden like Win+L. It is acting like the back key which you'd expect from that shortcut.

Lemme restart the machine i can't

mrshanepaul commented 3 years ago
2. One i can't is having Alt+Left act like it can't be overridden like Win+L.  It is acting like the back key which you'd expect from that shortcut.

The reason I chose these particular key combos because they are the special "Web Back/Forward" keys on my keyboard.

I don't need them for that, but they work well for music. :)

Is it possible that another app is stealing/conflicting this combo for its own purposes? I know some apps will do this with other combos, and you have to unbind them first.

mykhailopylyp commented 3 years ago

@mrshanepaul Just to clarify. If we have the following remapping image

If Ctrl+Alt+Left is pressed, it will be remapped to Ctrl+Next Track(So Spotify still captures Next Track). It is by design. Isn't it part of your issue?

Let's assume we use an application that has Ctrl+Alt+Left shortcut. If we press Ctrl+Alt+Left the application will get Ctrl+Next Track(because it is remapped by PowerToys). Isn't it the second part of your issue?

mrshanepaul commented 3 years ago

@mykhailopylyp That would explain it then.

Unfortunately that means that using an Alt bind like this will ruin all other combinations of meta keys that include Alt. They will be forced to be permutations of whatever is bound to the base combination?

I did not know it worked this way, I am not sure it should?

Or at least be configurable to not do this?

What happens if I Bind bother "Ctrl+Right" AND "Alt+Right". And then press Ctrl+Alt+Right?

I am not sure a single key bind should do this?

PS: I also tried to bind the combo back to itself to try to override whatever was happening, but you are not allowed to do that. :)

enricogior commented 3 years ago

@crutkas @mrshanepaul @mykhailopylyp I think we need to fix this, since the default behavior should be that only the exact shortcut is remapped, any other shortcut that contains the given shortcut as a subset should not be affected. We may consider the current behavior as an option if someone really wants to affect all shortcuts that contains the given one, but I see it has a low priority option.

CORRECTION: since only shortcut to key mapping are affected by this behavior, and since this is the current documented behavior, the only change we can consider is to add an option to also force exact shortcut to key mapping.

mykhailopylyp commented 3 years ago

@mrshanepaul You can try something like image to solve your issue.

If you press Alt+Right it will still send Next Track and it will not remap Shift+Alt+Right.

mrshanepaul commented 3 years ago

@enricogior That would be excellent. As part of the upgrade, existing user config could be set to preserve the original functionality while newly created key binds revert to the new method?

@mykhailopylyp Thanks a lot for that. I tried that out and it works great. The 2-key combo does not override everything. This would not work in most cases but meta-key combinations are ignored by the music player so it does.

Thanks!

kalokng commented 3 years ago

I also have a similar issue: I am using a Mac keyboard with F13~F19 which has no use in windows, and I mapped them as volume / media control keys:

F13 -> volume mute Ctrl+F13 -> Play / pause Media

But whenever I press Ctrl+F13, it always mute / unmute the volume. I tried to remove the F13 binding, then Ctrl+F13 works as intended.

mrshanepaul commented 3 years ago

But whenever I press Ctrl+F13, it always mute / unmute the volume. I tried to remove the F13 binding, then Ctrl+F13 works as intended.

Could be due to a quirk of the keyboard standard. :)

F13 == Shift F1

So Ctrl F13 would be Ctrl Shift F1. (I think)

Might be a cause of the issue somehow?

mykhailopylyp commented 3 years ago

@kalokng

F13 -> volume mute Ctrl+F13 -> Play / pause Media

But whenever I press Ctrl+F13, it always mute / unmute the volume.

It is expected. We map key to key first and it does not matter if a key is a part of a shortcut. In your example, when you press Ctrl+F13, F13 is remapped to volume mute so the system receives Ctrl+volume mute.

lukeng commented 3 years ago

@mrshanepaul

Could be due to a quirk of the keyboard standard. :)

F13 == Shift F1

So Ctrl F13 would be Ctrl Shift F1. (I think)

Might be a cause of the issue somehow?

No, keyboard manager can correctly identify F13 and Shift+F1. And when I press Shift+F1, the volume did not mute.

@mykhailopylyp

@kalokng It is expected. We map key to key first and it does not matter if a key is a part of a shortcut. In your example, when you press Ctrl+F13, F13 is remapped to volume mute so the system receives Ctrl+volume mute.

I am a bit confused with that behavior, as I can do both bindings in v0.35.

Btw, I found a workaround which achieve what I wanted:

F13 -> Volume Mute Ctrl + Volume Mute -> Play / Pause media

Maybe some text showing somewhere in the dialog when creating the shortcut would help.