microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
109.07k stars 6.43k forks source link

[KBM] Multi Keyboard Support #1460

Closed evilC closed 4 years ago

evilC commented 4 years ago

https://github.com/microsoft/PowerToys/wiki/Keyboard-Manager#18--solutions-or-expectations

To me, this implies the ability to have keyboard-specific hotkeys - for example if I have a separate USB numpad and wish to remap the keys on it whilst suppressing the native functionality of the key, but not to affect the native functionality of the same key on my main keyboard. eg Remap Numpad1 on the second numpad keyboard to MediaPlayPause, but not affect the functionality of Numpad1 on my main keyboard.
None of the software that I am aware of supports this. HID can differentiate devices but cannot suppress input. Hooks can suppress input but cannot differentiate devices. The only solution that I am aware of to do this is the Interception keyboard filter driver - I have written an AHK wrapper for this, but it is not natively supported by AHK Can you please clarify whether this is what is meant by the term, and if you plan to support some way of doing this in PowerToys?

mattague commented 4 years ago

If you read farther down, they describe it pretty well. Section 2.1 Priority 7 States "Multiple keyboard support. Example: Surface Laptop and Surface keyboard have different layout and a remap maybe needed."

Section 4.3/4.4 show the ability to select individual keyboards and how the user would edit individual shortcuts on each keyboard

crutkas commented 4 years ago

yup, goal is to allow different keyboards and have them remapped accordingly. We're unsure this is possible but that is the goal. We're going to close this out as it is being tracked in via the spec

saahmedm commented 4 years ago

just as an update, this is currently not available to do with public APIs, and we're working to change that. as a result of prioritization of key features and the work this would take, we're pushing this back and it will not be part of our V1. still working on it though!

TheBestPessimist commented 3 years ago

I am also interested in this functionality.

I have found these links, which say that using RawInput, we are able to differentiate the keyboards:

Would this help with implementing multiple keyboards support?

evilC commented 3 years ago

RI can differentiate between keyboards, but has no blocking, so cannot suppress the native functionality of the key from the second keyboard There's an interesting article here about combining hooks and rawinput though to achieve that goal

enricogior commented 3 years ago

@crutkas we should add this information in the wiki, since users keep asking for this feature.

crutkas commented 3 years ago

@enricogior done https://github.com/microsoft/PowerToys/wiki/Keyboard-Manager-Overview#5-multi-keyboard-support

wsltshh commented 3 years ago

Separate mapping of multiple keyboards is useful, hope to realize this function as soon as possible

krisalcordo commented 3 years ago

This would be an amazing feature to have.

franky920920 commented 2 years ago

@enricogior done https://github.com/microsoft/PowerToys/wiki/Keyboard-Manager-Overview#5-multi-keyboard-support

@crutkas I cannot find this in docs.microsoft.com. 😕 Is this removed for some reason?

crutkas commented 2 years ago

https://github.com/MicrosoftDocs/windows-uwp/pull/3475

lxg208 commented 2 years ago

Please consider adding this feature, it is extremely useful.

For others with similar needs, LuaMacros http://hidmacros.eu/ works somewhat. However, it's not very consistent. And its documentations are very limited, the inconsistency may be the result of me not figuring out how to do it in LuaMacros. You may have better luck than me.

glauc0 commented 2 years ago

I am excited to see this feature working.

garretwilson commented 2 years ago

This would be really useful. Has this ticket really been closed?

I note that the Karabiner Elements for Mac allows different key mapping for different keyboards.

This is really needed in my case:

Obviously I don't want to have these remappings on all the time. Even if PowerToys at least allowed me to manually choose a list of settings from a drop-down would be better than nothing, although keyboard detection would be ideal.

This is pretty much the main reason I'm using PowerToys. Is there another utility that already has keyboard detection?

crutkas commented 2 years ago

Issue is to best of our knowledge, there isn’t currently a solid API to detect which keyboard which input came from with how we do input. If we flip to scan code or another method, we will revisit this but as of now, our system isn’t compatible

this was one of our goals when we started out.

cjbarth commented 2 years ago

there isn’t currently a solid API to detect which keyboard which input came from with how we do input

This is a problem I've experienced with other keyboard-related projects I've worked on. Is there a way to get the Windows team involved here so they can either provide guidance or update the APIs in Windows to allow for this very useful feature? The usefulness extends well beyond convenience and really allows some powerful interactions in multi-keyboard scenarios (video editing, CAD, broadcasting, gaming, programming, etc.).

wingdagger commented 2 years ago

I also would really like to have this feature. I use an external Bluetooth keyboard and I need to remap the Alt and Windows keys to make them consistent with the laptop's built-in keyboard. Thank you!

teceoh commented 1 year ago

It would be perfect if it was in PowerToys. I currently use Macros MultiKeyboard, but I don't like the interface and especially the price.lol

garretwilson commented 1 year ago

An update on my situation: I've switched to AutoHotkey and turned off PowerToys.

Even if PowerToys can't detect the keyboard, it could at least allow me to configure different named groups of hotkeys (e.g. one for each keyboard), and provide a hotkey to switch among them (analogous to switching languages on Windows). But in PowerToys it's all-or-nothing. I can't even manually go in and choose a group of hotkey definitions. And if I remember correctly, it doesn't support hotkeys using Win. So as far as the keyboard mapping is concerned, there isn't much "power" in PowerToys.

This is what I was wanting PowerToys for, so since it doesn't support this use case, I've abandoned it.

mngyng commented 1 year ago

An update on my situation: I've switched to AutoHotkey and turned off PowerToys.

Same here. Placed a AHK script in my Windows startup folder, by default turned off. Edit my script to do the mapping, and used F1 key to toggle on/off the mapping. Here's my script:

Suspend, on
RCtrl::Del
End::PgDn
Home::PgUp
PgDn::End
PgUp::Home
NumLock::F12
F1::Suspend,Toggle

Used this mapping on a laptop for easier access of the Del/Home/End/F12 buttons, and keep it flexible if I want to plug in a keyboard/mouse/monitor combo for a comfy production setting.

Found somewhere saying plugin events of USB keyboards could be used in an AHK script, but so far I'm happy using F1.

The problem with PowerToys is that it takes too many clicks to get to the keyboad mapping part, and to make it worse there's no way to create and pin a shortcut of PowerToys to the taskbar.

TheBestPessimist commented 1 year ago

Found somewhere saying plugin events of USB keyboards could be used in an AHK script, but so far I'm happy using F1.

hey @mngyng, I have a script doing exactly that. Please see the function changeKeyOrderByDetectingUSBKeyboard from https://github.com/thebestpessimist/autohotkey-scripts/blob/8271e3330ab0b81146355ab1ec027164dd882b8a/XmgFusion15.ahk

Basically, i want to do the following:

#If !usbKeyboardAttached (if my external keyboard is *not* attached, change some keys)
{
     PgUp::PgDn
     PgDn::Home
     Home::PgUp
}
#if
TheBestPessimist commented 1 year ago

I suggest you create an issue in my repository, so that we don't spam everybody.

In this case, the explanation is right there in the error: The function "saveClipboard()" does not exist in your scripts. Probably because you copied only that single file. Please delete the call and it should work.

mngyng commented 1 year ago

Found somewhere saying plugin events of USB keyboards could be used in an AHK script, but so far I'm happy using F1.

hey @mngyng, I have a script doing exactly that. Please see the function changeKeyOrderByDetectingUSBKeyboard from https://github.com/thebestpessimist/autohotkey-scripts/blob/8271e3330ab0b81146355ab1ec027164dd882b8a/XmgFusion15.ahk

Copied <saveClipboard()> and <restoreClipboard()> from one of your other .ahk files, replaced the hardware ID in the code with my keyboard ID and finally made it work.

Thank you so much! I've wanted to make this work for like the entire last year.

ghost commented 1 year ago

If it is not available in the current api, can’t we even have multiple configs and manually turn it on and off?

I would accept the cost of changing them manually. But currently, we don’t even have the ability to have multiple configs, so we need to change whole configs one by one

valinet commented 2 months ago

Almost 5 years have passed and Windows still doesn't include an API for this uber requested feature. Good thing they are pushing Recall though, it was much needed./s