Categories
Design

How to use caps lock as a modifier key on windows

Chris Hoffman is Editor-in-Chief of How-To Geek. He’s written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times, been interviewed as a technology expert on TV stations like Miami’s NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read nearly one billion times—and that’s just here at How-To Geek. Read more.

The Caps Lock key takes up prime keyboard real estate, and it isn’t pulling its weight. This easy AutoHotkey script will turn Caps Lock into a modifier key so you can use it for customizable shortcuts.

The Basics

This script will let you press Caps Lock+G to quickly Google text from anywhere in Windows or press Caps Lock+D to look up the dictionary definition of a word. These shortcuts are customizable, of course.

Best of all, this clever script still lets you use Caps Lock normally. You can toggle Caps Lock on and off by quickly pressing it twice. If you don’t, Caps Lock will function as a modifier key for shortcuts.

AutoHotkey 101

AutoHotkey is a free Windows application that sits in the background and runs scripts. You can write these scripts yourself or download them. Scripts generally wait for a keypress and perform an action. In this way, AutoHotkey is a quick way of remapping keys in Windows or assigning different actions to keys.

For example, we’ve shown how you can use AutoHotkey to disable the Windows key, preventing it from opening the Start menu and taking you out of full-screen PC games. No need to pry the keycap off the keyboard.

Install AutoHotkey and Get the Script

Extract the AHK script file from the ZIP archive file and place it in any folder on your computer. To run it with AutoHotkey, right-click the script and select “Run Script.”

How to use caps lock as a modifier key on windows

The script is now running in the background. To toggle Caps Lock on and off, quickly double-tap the Caps Lock key.

If you don’t double-tap, Caps Lock just functions as a modifier key. With the functions built into the script, you can use the following shortcuts anywhere in Windows:

  • Press Caps Lock + d to find the dictionary definition of a selected word.
  • Press Caps Lock + g to search Google for the selected text anywhere in Windows.
  • Press Caps Lock + t to find the selected word in a thesaurus.
  • Press Caps Lock + w to search for the selected text on Wikipedia.

To control AutoHotkey, look for the AutoHotkey icon in your notification area—it has a green background with a white H on it. To stop running the script, just right-click the AutoHotkey icon and select “Exit.”

How to use caps lock as a modifier key on windows

How Does It Work?

If you’d like to see what the script does, right-click it and select “Edit Script” instead. This will open the script in Notepad, and you can examine its code. The script is pretty short and easy to understand. We recommend not downloading and running strange scripts without looking at them and understanding them first.

This script was sent to us by Dave Kellog. Here’s the magic part of the script that makes Caps Lock function as a modifier key if it’s pressed twice:

This bit waits to see if Caps Lock is pressed twice and sets Caps Lock on or off. Otherwise, the script captures Caps Lock and uses it for modifier shortcuts.

The rest of the script contains the shortcut actions and a helpful clipboard function that saves the contents of your clipboard and restores them. That part is pretty necessary, as the modifier functions use the clipboard to take actions on the selected text.

Want to see the full script without downloading it? Here it is:

We’ve seen AutoHotkey scripts that turn Caps Lock into a modifier key before, but never one that keeps Caps Lock around as a toggle if you double-press it. It’s very clever. Thanks again to Dave Kellog for sending it to us.

How to use caps lock as a modifier key on windows

I know that a lot of people have asked questions about turning capslock into a control key, but my problem is a little different.

I want to use the capslock as its own modifier key. When I am holding the capslock key, I want to be able to use i,j,k, and l as arrow keys, along with some other, similar modifications like that. But because I use programs that use ctrl+j or ctrl+i, etc. for application-specific functions, I don’t want to just assign it to control. Here is what I have tried:

The problem with that is that if I press anything besides one of the hotkeys I have defined (i,j,k,l) the capslock will toggle. The desired behavior would be that if I press Capslock & anything else, nothing happens at all.

The problem with this is that it works, but only one time. For example, if I hold down capslock, and press ‘i’ three times, it will arrow up the first time, and then type ‘i’ twice. I need to be able to hold capslock down and use ijkl as arrow keys, so this won’t work either.

But this was always sending Ctrl+Up instead of just Up.

I have tried all sorts of combinations of * $ and

, as well as scrambling the order of things around, and none of it has fixed my problems. Maybe I am trying to do something that just can’t be done, but there has got to be some way that I can use capslock as a modifier key without losing my ctrl, alt, and shift keys for their regular functions. Any suggestions would be greatly appreciated.

I want to use both my Caps Lock key and Windows key in my i3wm config. In particular, I want Caps Lock to take the place of $mod in the config and I also want to be able to reference the Windows key in bindsym . How would I do this?

Currently, I’m able to use my Caps Lock key as $mod but I want to also use my Windows key now, as a different modifier.

My .Xmodmap is currently

and the keycode to my Caps Lock key is 133.

How to use caps lock as a modifier key on windows

1 Answer 1

The issue here is that you are essentially removing the Windows keys from the modifier list with clear mod4 . In order to have Caps Lock available as an additional modifier instead as a replacement of the Window keys, you would have to set it to a different modifier. You can use modifiers Mod1 through Mod5 in addition to Control , Shift and Mode_switch with i3.

First check, if any modifiers are unused in the the layout you are using (without applying your .Xmodmap ). You can get a list of the modifier settings with xmodmap -pm . For the us layout this returns (on my machine):

As you can see mod3 is currently unused. In order to use it you just have to put the following into your .Xmodmap :

Note: In this case I used Hyper_R because Hyper_L was already bound to mod4 . And 66 is the key code of Caps Lock. This may be different on your machine.

Now you can use this modifier with your i3 keybindings. If you want to keep using the $mod variable with your configuration just set it to either Mod3 or Mod4 depending on if you want to use Caps Lock or the Windows keys for that. But There is no real need to actually use it (It is mainly convenience to ease up first time setup when choosing between Alt ( Mod1 ) and Windows keys ( Mod4 ).

Why switch caps lock for control

This is something that I have done on every machine I own for years. As a developer I spend a good portion of my day using the terminal. Being obsessed with efficency, I try to use my keyboard for everything as moving my hands to use a mouse/touchpad is not efficient. The use case for mapping caps lock to control is simple; I use control more often than caps lock and I do not need my fingers to leave the home row to press the key that is next to “a”. When I was using a mac this was useful mainly for jumping around the command line and there is some decent support for EMACS-style navigation in OSX (for example, CTRL+A to get to the beginning of a line could be used in web browsers).

This is even more useful on Windows and Linux systems because you use the control key for many common things (copy, paste, undo, redo, etc…).

How to make the swap

There are two straight forward ways to do this

PowerShell

This is the easiest way. To start open Windows PowerShell (Admin) by pressing Win + X . Then enter these commands:

Save and reboot.

PowerToys

PowerToys is a tool created by Microsoft that enables users to customize their Windows experience in a visual interface. It is open source and can be installed from Here

Once Installed go to the Keyboard Manager tabl and click Remap a Key. Select caps lock to control and you’re good to go.

I want to use both my caps lock key and windows key in my i3 config. In particular, I want caps lock to take the place of $mod in the config and I also want to be able to reference the windows key in bindsym. How would I do this?

Currently, my .Xmodmap is

and my i3 config has a line

With this configuration, my windows key behaves like the mod4 key, but I don’t want this. I want to be able to press Windows+a and have it behave differently than Capslock+a.

Comments

Do you want to use the windows key as Modifier or as (the last) key?

Could you edit the question to show how you got Caps Lock to work as modifier? It is not something i3 can do by default, so I assume you remapped it (with xmodmap?) to some other key. Then would be the question if you want the Windows key to be the same modifier as Caps Lock or a different one.

2 answers

The issue here is that you are essentially removing the Windows keys from the modifier list with clear mod4 . In order to have Caps Lock available as an additional modifier instead as a replacement of the Window keys, you would have to set it to a different modifier. You can use modifiers Mod1 through Mod5 in addition to Control , Shift and Mode_switch with i3.

First check, if any modifiers are unused in the the layout you are using (without applying your .Xmodmap ). You can get a list of the modifier settings with xmodmap -pm . For the us layout this returns (on my machine):

As you can see mod3 is currently unused. In order to use it you just have to put the following into your .Xmodmap :

Note: In this case I used Hyper_R because Hyper_L was already bound to mod4 . And 66 is the key code of Caps Lock. This may be different on your machine.

Now you can use this modifier with your i3 keybindings. If you want to keep using the $mod variable with your configuration just set it to either Mod3 or Mod4 depending on if you want to use Caps Lock or the Windows keys for that. But There is no real need to actually use it (It is mainly convenience to ease up first time setup when choosing between Alt ( Mod1 ) and Windows keys ( Mod4 ).

After we showed you how to disable the Caps Lock key , reader Philipp wrote in with his unbelievably geeky use for the otherwise pointless key—by using it to help navigate while editing text.

NumLocker Disables the Caps Lock Key

Windows only: Tiny application NumLocker disables the Caps, Num, and Scroll Lock keys from an…

Philipp’s idea was to use the Caps Lock key as a way to toggle keys on the front row for navigation instead of having to constantly reach for the arrow keys—so you hold down Caps Lock and use J, K, L, I to move the cursor Left, Down, Right, and Up.

He took it a few steps further and added keys that simulate Home, End, and even copy/paste—might be a little complicated to learn at first, but once you get used to it, you might just be sold on the idea. Since he implemented all the functionality as an AutoHotkey script, you can easily adjust it to fit your own needs—I’m working on my own version that uses the vim keys instead.

The list of functions includes:

Normal usage with capslock as a modifier:
j: left
k: down
l: right
i: up
h: simulates CTRL+left (jumps to the next word)
ö: simulates CTRL+right (commented out, you will need to adjust for your keyboard layout)
,: simulates CTRL+Down
8: simulates CTRL+Up
u: simulates “Home” (jumps to the beginning of the current line) (i forgot to mention this in my comment)
o: simulates “End”
Backspace: simulates “Delete”
b: cut
c: copy
v: paste

If you keep pressing Alt in addition to Capslock it works as if you are pressing “Shift” —> you highlight the text. Shift + Capslock activates the actual Capslock functionality (normal capslock-hitting deactivates it again).

Comments

kuroikyu commented May 20, 2020

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!

The text was updated successfully, but these errors were encountered:

We are unable to convert the task to an issue at this time. Please try again.

The issue was successfully created but we are unable to update the comment at this time.

eric6356 commented May 20, 2020

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

beorereleverion commented Jul 30, 2020

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

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.

Desktop screen readers are usually controlled with the keyboard only. Offering tons of functionalities, all of them ought to be triggered by keyboard shortcuts. But what to do if none of the standard keyboard combinations are available anymore?

Problem: no keyboard combinations left

Most traditional keyboard shortcuts (a combination of at least one modifier key and any other key, if you haven’t done this yet, go back and read Controlling a computer with a keyboard only) are already in use by the operating system and running applications.

Solution: using Insert as modifier key

Both screen readers NVDA and JAWS worked around this problem by hijacking the Insert key as their modifier key. So most interaction with desktop screen readers involves a combination of Insert and other keys.

  • When running NVDA:
    • Insert + N shows the NVDA menu.
    • Insert + F7 shows the elements list (with links, headings, landmarks, etc.).
  • When running JAWS:
    • Insert + J shows the JAWS menu.
    • Insert + F6 displays the heading list.

Alternatives to the Insert key

If you’re on a Mac running NVDA or JAWS in a virtual machine, there are several ways you can work around the missing Insert key; if you haven’t done this yet, go back and read Configuring VMware Fusion on macOS.

Both NVDA and JAWS offer the option to use Caps Lock instead of Insert as a modifier key. For some reason though, this does not seem to work in VMware Fusion.

Naming convention

In this guide, we do not talk about the Insert key. Instead, when running NVDA, we talk about the NVDA key. And when running JAWS, we talk about the JAWS key.

So the examples above look like this:

  • When running NVDA:
    • NVDA + N shows the NVDA menu.
    • NVDA + F7 shows the elements list.
  • When running JAWS:
    • JAWS + J shows the JAWS menu.
    • JAWS + F6 displays the heading list.

For a complete guide of shortcuts please read on.

How to use caps lock as a modifier key on windows

Hello AHK Community.

This is my first post here, however I have been browsing the forums for quite some time now. I’ve noticed how open and helpful the community is, and decided I might as well become part of it, as I am starting to get into more complex scripts and may need a hand somewhere down the road.

Anyways here is a script I wrote using this post

This script is a modified version of the one found above. Mine allows you to keep/prevent Capslock functionality while using it as a modifier key.

If capslock is released after you have pressed a hotkey, capslock will not be toggled on release.

If a hotkey was not pressed, capslock will toggle as expected.

Please feel free to suggest any improvements or changes. I realize that this is not a very complex script, but it may help someone out.

  • Members
  • 567 posts
  • Last active: Dec 01 2014 07:59 PM
  • Joined: 17 Jun 2008

And why not only CapsLock & a:: MsgBox,CapsLock & a ?

How to use caps lock as a modifier key on windows

  • Members
  • 6 posts
  • Last active: Dec 13 2012 06:49 PM
  • Joined: 09 Dec 2012

And why not only CapsLock & a:: MsgBox,CapsLock & a ?

Because this toggles capslock.

My method posted above prevents capslock from being toggled when a hotkey is pressed, but still allows capslock to function when a hotkey is not pressed.

  • Members
  • 567 posts
  • Last active: Dec 01 2014 07:59 PM
  • Joined: 17 Jun 2008

At me, it doesn’t.

How to use caps lock as a modifier key on windows

  • Members
  • 6 posts
  • Last active: Dec 13 2012 06:49 PM
  • Joined: 09 Dec 2012

Strange, what OS are you using? and does pressing capslock alone usually toggle Capslock on your PC or Do you have other scripts interfering with caps lock?

I am on Windows 7 Home Premium, and the alternative you posted toggles my capslock.

  • Members
  • 567 posts
  • Last active: Dec 01 2014 07:59 PM
  • Joined: 17 Jun 2008

I have Win7 64 Prof.

How to use caps lock as a modifier key on windows

  • Members
  • 2 posts
  • Last active: Jun 16 2013 02:16 PM
  • Joined: 14 Feb 2013

Couldn’t wait to play with this and it works perfectly. No lag at all toggling capslock, and it works fine as a modifier.

Ah, definitely going to try this out. It’s been bugging me forever and I could never figure out how to get around the Capslock problem.

I’ve wanted to use it as a modifier for vim-like keys. Hold capslock then use the usual hjkl as arrow keys.

But on my system (Windows 64 Ultimate), it would never work properly.

The very FIRST time you hold down and capslock and press j, it’ll send a left. Release capslock then try it again and it doesn’t work. It’ll simply send out a j.

I’ve been using Tab as the modifier, but would love to switch as caps is easier to press.

I tried with other keys like space, or f, but the problem with those is the lag introduced when using a key as a modifier. When I type rapidly, the system won’t send out the key at all sometimes. Tab is the only key before that wasn’t used during rapid typing.

I’ll update this post when I’ve had some time to play with this.

  • Members
  • 1 posts
  • Last active: Feb 24 2013 03:02 AM
  • Joined: 23 Feb 2013

The code in the first post wouldn’t work on Windows 7 x64. I have no idea why really, but I modified the code and got something to work:

The notes I would add are:

– I didn’t particularly care about Capslock toggling upper/lowercase letters intentionally or not along with the ‘; do something here‘.

– using ‘1‘ in the code ‘Gui, 1‘ is the only number that worked, not any other number between 2-99.

– the GUI is created at the bottom-right corner of a 1080p screen, adjust accordingly.

  • Members
  • 1 posts
  • Last active: Mar 12 2014 04:29 PM
  • Joined: 12 Mar 2014

Hello AHK Community.

This is my first post here, however I have been browsing the forums for quite some time now. I’ve noticed how open and helpful the community is, and decided I might as well become part of it, as I am starting to get into more complex scripts and may need a hand somewhere down the road.

Anyways here is a script I wrote using this post

This script is a modified version of the one found above. Mine allows you to keep/prevent Capslock functionality while using it as a modifier key.

If capslock is released after you have pressed a hotkey, capslock will not be toggled on release.

If a hotkey was not pressed, capslock will toggle as expected.

Very new to the scene but I got your script to work with Capslock as the modifier!

I wanted to add a few more commands that uses Capslock as well but I couldn’t add more hotkeys directly after another.

The noob me then decided to reduplicate the entire shortcut/hotkey area to add more shortcuts using Capslock like the following:

Looks dumb but it works lol. But the thing I wanna is; is there any other way to add more hotkeys without having to do what I just did?