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

[KBM] CapsLock as a modifier in Remap Shortcuts #3326

Open
kuroikyu opened this issue May 20, 2020 · 20 comments
Open

[KBM] CapsLock as a modifier in Remap Shortcuts #3326

kuroikyu opened this issue May 20, 2020 · 20 comments
Labels
Idea-Enhancement New feature or request on an existing product Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager

Comments

@kuroikyu
Copy link

Dozens of us don't use Caps Lock at all during our normal workflow (dozens!), so it would be nice to be able to use it as an extra modifier when using the Remap Shortcuts functionality.
This is already a thing in macOS world thanks to tools like Karabiner Elements or BetterTouchTool that allow yout to turn Caps Lock into the "Hyper" modifier as it's commonly refered to. I'm sure there's something similar for Linux but I'm not that familiar with it.

In terms of implementation, I don't mind if Caps Lock is not recognised as a modifier straight away since maybe other people don't see it that way. I would be fine using Remap keyboard to map Caps Lock to this new virtual "Hyper" modifier so I can start using it for my Remap shortcuts.

Thanks for the tool by the way, I'm going to start moving most of my maps from AHK to the PowerToys!

@saahmedm saahmedm added the Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager label May 20, 2020
@eric6356
Copy link

My AHK key mappings are not working in the PowerToys Run popup window, they used to be fine in the Window Walker.😢

@saahmedm saahmedm added Issue-Feature A planned feature addition to a product Idea-Enhancement New feature or request on an existing product labels Jul 13, 2020
@saahmedm saahmedm added this to the Suggested Enhancements milestone Jul 13, 2020
@beorereleverion
Copy link

I also use this to change the layout. Accustomed to linux, took the idea from Mac

@arjunbalgovind
Copy link
Contributor

arjunbalgovind commented Oct 30, 2020

@crutkas this is one of the highly requested features. In terms of implementation details I was thinking of something along these lines:
UI: On the landing page, a user has the option to use Caps as a modifier. This has two effects:

  • Caps Lock will no longer work as before, it will behave as if it were orphaned. So you can't turn Caps Lock on/off. If the user was stuck in the Caps on state before orphaning it, it's up to them to disable the remapping and fix it manually.
  • Caps Lock should be selectable as a modifier in the Remap key and shortcut window, and no longer considered as an action key,
    We have to fix it to be one of the two behaviors, either modifier or action key, can't have both.

Implementation in the backend (Pseudo-C++ code):
We can't use GetAsyncKeyState for checking if Caps Lock is pressed, since we have to suppress Caps Lock events to prevent the oridinary behavior. Instead we have to workaround this by having our own bool variable which updates CapsLock state on receiving Caps key events. This is equivalent to storing our own keyboard state variable rather than using GetAsyncKeyState.

// Assume a bool variable is present in KBM state or some class like that which stores the state of Caps Lock.
// Assume Caps+A is remapped to Ctrl+V
Remap_method()
{
    // Suppress all caps lock events and update state
    if (CapsLockModifierBehavior && current key=CapsLock)
    {
       UpdateCapsLockBoolState(currentKeyEvent->keyUpOrDown);
       return 1;(suppress)
    }

    if (currentKey = A)
    {
         if (CapsLockState is pressed)
         {
             // Remap to Ctrl+V (same as existing logic). Wherever we reset back to the pressed modifiers, we can still sendInput CapsLock, but it should get read by the `UpdateCapsLockBoolState` method.
         }
    }

}


Possible quirks:

  • Since we aren't using GetAsyncKeyState quirks can occur if a user switches between elevated and unelevated windows. We can guarantee it would work correctly only if elevated. This was the same thing that occurred in the original PT Run and ColorPicker hook implementations as modifiers were recorded in bool variables rather than using GetAsyncKeyState.
  • We should make sure this doesn't break Narrator support. Caps Lock is an important key for accessibility and Narrator. Narrator runs at a lower level so this might not be an issue, but should be double-checked. If not this could be marked as a "non-accessible" feature with appropriate warnings.

@Zeroto521
Copy link

Well, I have used Caplos. It's great in some ways.
But it still has some problems.

@AdamRatai
Copy link

As poster said - It is possible to turn off caps lock (and ins), by disabling it, but for example in my case I would like to still use it, but using ctrl + capslock and rcontrol ins to turning them on and off (I'm 44 and it is highly unlikely that after hitting Caps by mistake for 25 years I'll finally learn it) . I can Add that remapping is bit confusing too. anyway, I tried to remap it in both possible ways and its not working. At least I can disable it, but its not ideal (thats why i leave ins as it is).
image

@Wulfheart
Copy link

What is the state of this right now?

@hwooo
Copy link

hwooo commented Mar 23, 2021

It would be really great if I can disable caps lock, and use it as first modifier of another shortcuts. (e.g. Caps Lock + W/A/S/D -> Up/Left/Down/Right)

@AmeroHan
Copy link

AmeroHan commented Apr 19, 2021

Caps Lock is a rarely used key, but it occupies the golden position. If we use Caps Lock shortcuts to enhance our typing, you can do some nice work without moving your hand far away.

e.g.

  • Caps Lock + E/S/D/F -> Up/Left/Down/Right
  • Caps Lock + I/J/K/L -> Shift + Up/Left/Down/Right
  • Caps Lock +W/R -> Backspace/Delete
  • ...

Just as Capslock+ do, it is especially convenient for we programmers and those who have no arrow keys on their keyboard.

@AdamJel
Copy link

AdamJel commented Jun 25, 2021

Yes, this would be a great feature! Having CapsLock as a modifier, so CL + hjkl = arrows. That would be a golden solution for non-arrows keyboards. It is arguably even the only solution, since all other modifiers have some functions. In vscode, Ctrl+Shift+Alt+arrows = multi cursor editing modification. Using any of [Ctrl, Shift, Alt] breaks this functionality. Therefore, the only solution is yet another modifier => CapsLock. (Using combo CapsLock+Ctrl+Shift+Alt isn't exactly user-friendly either, but if the keyboard does not have arrows, it is IMO still the best solution).

Or, perhaps, allowing even Tab as a modifier, further simplifies this. If Tab is clicked alone, it is still a tab, elif it is pressed and other key follows, it acts as a modifier. Then, we can have all above with this tweak: CapsLock+Ctrl+Shift+Alt(+arrows) = CapsLock+Tab(+arrows).

Little extra: it would be nice, if clicking the CL and pressing it could have different mapping. E.g. CL+hjkl = arrows, but just clicking CL = Esc (no more pinkie torture).

@AdamRatai
Copy link

I gave up and just turned off caps lock key permanently, and I can turn it on byt rcontrol+tab. Still workaround.

@AdamJel
Copy link

AdamJel commented Jun 29, 2021

Just as Capslock+ do, it is especially convenient for we programmers and those who have no arrow keys on their keyboard.

It seems interesting. Though, I made a simple one myself, which also could be a start place for others. Take a look here.

@timblaktu
Copy link

+1 for same reasons. I use Autohotkey to disable caplock, and map CL-hjkl to arrows and other combinations to mimic my minimal AnnePro keyboard. Just got a new laptop for work, and thought I would try out keyboard manager and power toys to do the same thing. So here I am. I will just use AHK and move on until this is resolved.

Many more than dozens @kuroikyu!

@JonTheBurger
Copy link

For what it's worth, I was able to emulate this behavior in v0.53.3 by remapping CapsLock to Right Alt, then mapping Right Alt + HJKL to arrow keys. So as long as recursive remaps are supported, there's a workaround.

@kulukimak
Copy link

For what it's worth, I was able to emulate this behavior in v0.53.3 by remapping CapsLock to Right Alt, then mapping Right Alt + HJKL to arrow keys. So as long as recursive remaps are supported, there's a workaround.

I get button presses (hjkl) when I press multiple keys while holding capslock when I try this workaround.

@forkercat
Copy link

@kulukimak I was also seeing this issue. I mapped CAP to right control instead. But repeating might cause the issue you mentioned.

@kulukimak
Copy link

kulukimak commented Aug 18, 2022

Pressing a key while a modifier and another key is pressed shouldn't send the unmodified second key. The problem is documented in this issue.

@luciodaou
Copy link

Just to add to the discussion, Karabiner-Elements on Mac allows for normal Caps Lock operation on a short press, and as a modifier if hold/kept pressed. I believe that would be the perfect behavior.

Otherwise, a suggestion is that Shift+Caps Lock could make it work as normal Caps Lock.

@taiottavios
Copy link

Just to add to the discussion, Karabiner-Elements on Mac allows for normal Caps Lock operation on a short press, and as a modifier if hold/kept pressed. I believe that would be the perfect behavior.

Otherwise, a suggestion is that Shift+Caps Lock could make it work as normal Caps Lock.

I would argue that the perfect behavior would be to have the option to make it do this or something else entirely (I would like to turn caps lock on with Win + CapsLock, and have it normally treated as a modifier key), and also to bind the keyboard lighting indicator to the lock state, instead of to the key state (when used as a modifier and held down, it would still light up as if the caps lock was active)

@bubbavox
Copy link

bubbavox commented Jun 24, 2024

Yes Caps Lock is in a prime spot. I swapped Control and Caps on each of my machines, via registry, using an app called SharpKeys. But anyways I think lots of folks would appreciate being able to use any key as a modifier key in PowerToys. There are all kinds of weird specialized workflows out there. Personally, I use Space as a modifier for cursor navigation (pseudo-vim aka SpaceFn). I achieve this with a program called TouchCursor. I wish it were possible in PowerToys though.

@JayJabowski
Copy link

As a workaround that worked really well for me, i use Win(Right) as the modifier key that is mapped to caps lock. On the keyboards I regularly use (notebook and external), there is no right Windows Key so for me, that's the free modifier I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea-Enhancement New feature or request on an existing product Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager
Projects
None yet
Development

No branches or pull requests