At work I have a Windows PC. I don’t have much personal experience with Windows which is why I am asking.

I want to remap the caps lock key to function as a control key. Ideally, on a per-user basis as sometimes other people use the workstation and I don’t want to confuse them.

  • Was able to install Auto Hot Key. A test script worked. However I couldn’t find working instructions about how to do this specific remapping. Example scripts I found seem to have some conflict between v1 and v2 of AH.

  • I don’t have admin access however I could probably ask for something, but it would have to work immediately without a lot of fooling around. I will not be granted admin access to try a bunch of things til I find something that works.

What’s the best way?

  • dual_sport_dork 🐧🗡️@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    7 months ago

    The Microsoft PowerToys Keyboard Manager tool should allow you to do this.

    https://learn.microsoft.com/en-us/windows/powertoys/keyboard-manager

    You will probably need admin access to install it, however.

    Edit: Actually, apparently you don’t? I just installed it on my work PC here, and did not get any UAC prompts or anything. It can indeed reassign your caps lock key – I just tested this, and it works. (I mapped it to left ctrl.)

    • imaradioOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 months ago

      I tried installing Power Toys a while ago but the version of windows is too old to support it.

  • somnuz@lemm.ee
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    7 months ago

    Okay, so make a script, name it whatever you feel like and paste this:

    ; The keyboard hook must be installed.
    InstallKeybdHook
    SendSuppressedKeyUp(key) {
        DllCall("keybd_event"
            , "char", GetKeyVK(key)
            , "char", GetKeySC(key)
            , "uint", KEYEVENTF_KEYUP := 0x2
            , "uptr", KEY_BLOCK_THIS := 0xFFC3D450)
    }
    
    ; Disable Alt+key shortcuts for the IME.
    ~LAlt::SendSuppressedKeyUp "LAlt"
    
    ; Test hotkey:
    !CapsLock::MsgBox A_ThisHotkey
    
    ; Remap CapsLock to LCtrl in a way compatible with IME.
    *CapsLock::
    {
        Send "{Blind}{LCtrl DownR}"
        SendSuppressedKeyUp "LCtrl"
    }
    *CapsLock up::
    {
        Send "{Blind}{LCtrl Up}"
    } 
    

    Save it, run it and you should be good to go.

    edit: This is V2, just in case.

    • imaradioOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 months ago

      Thanks I will do this!

      Does this first line mean anything? I didn’t install anything except the basic AH package:

      ;The keyboard hook must be installed.
      
      • somnuz@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        It is just a comment for the InstallKeybdHook command just bellow it, as it is crucial for this magical code (that I don’t fully grasp yet) to work.

        But it does.

        • imaradioOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          7 months ago

          ah OK thanks!

          I will try this when I am at my workstation.

  • somnuz@lemm.ee
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    7 months ago

    Sorry for asking but is there any reason why caps lock? Because… You are a lucky winner of “choosing one of the most problematic keys to remap” award…

    • imaradioOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 months ago
      • I have small hands that makes certain key combos involving ctrl difficult/uncomfortable to reach
      • at home I have caps lock remapped and therefor I am constantly using it by muscle memory
      • Even before I had remapped it at home, I would sometimes enable it by accident which is annoying
      • in previous versions of windows (I think windows 8?) I could disable caps lock entirely in a system setting but it seems they have removed this option from more recent version
      • it’s right there
      • somnuz@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        Okay, all makes sense. When you are using the keyboard a lot, your comfort is most important. The worst part about Caps Lock is that it is more embedded into the system inner-workings, as for example — it is used for certain crucial shortcuts, especially when using Chinese language.

        • imaradioOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          7 months ago

          That’s interesting I didn’t know that. I used to share workstations with someone from indonesia who had what seemed like very strange habits of employing caps lock constantly. I assumed it was just a personal weirdsy but maybe it was due to use of caps lock in another linguistic context.

          However, I know for a fact that it doesn’t do anything I need. I’ve had it remapped for a couple years on personal machine without issues.

          Thanks for telling me though, because I will be sure not to fallback to the registry or another method that changes behavior system-wide. Would not want to prevent anyone else from using the device.

          • somnuz@lemm.ee
            link
            fedilink
            arrow-up
            2
            ·
            7 months ago

            Your idea to use AHK script is probably the best and least intrusive. You sit down, run the script, whatever you need can be in it, you can actually really tune your input experience with some AutoHotKey magic. I catch myself adding a few more lines every year as new ideas come.

            Just remember to unload the script when you are ending your work and the next person won’t even know about it.

    • dual_sport_dork 🐧🗡️@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      7 months ago

      I don’t see how it would be a problem unless you reassigned it while caps lock was enabled, in which case you would have to reboot (or temporarily revert your remap) to turn it off.

      I can think of precious little software that actually requires caps lock for anything, and otherwise for normal typist tasks you can just use shift. I never use caps lock for anything, personally. (Ditto with num lock. My keyboard has a full number pad and a full set of arrow/insert keys. There is no reason for my number pad to ever not be a number pad.)

      • somnuz@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        7 months ago

        I was asking because it is actually a problem for two reasons, one is that capslock has more states than other keys, plus it is more complicated to tinker with via AutoHotKey, they even documented it nicely buuut… the official method did not work for me — I just tested it.

        I did it in a hurry so there might be “me” problem somewhere too.

        Okay, it works.

      • imaradioOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        7 months ago

        At home, once in a while caps lock turns itself on somehow. I have a shell alias to fix the problem:

        UNCAPS='xdotool key Caps_Lock'
        

        Should this happen at work I was thinking to either temporarily disable the application that is doing the remapping, or use some sort of onscreen keyboard to inactivate the caps lock.

    • imaradioOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 months ago

      Oh sweet if there was a native windows option that would be best.

      Tho I feel like I might have tried this and it didn’t work somehow. I will try again when at my workstation.