Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In AutoHotkey v2, remap a key with OriginKey::DestinationKey. For example, CapsLock::Ctrl makes Caps Lock act as Ctrl while the script is running. To swap two keys, write a remap in both directions. You can also limit a remap to a particular window with #HotIf.

Make a basic key remap

These examples use AutoHotkey v2. Add a version requirement to the top of the script so the intended major version is clear:

#Requires AutoHotkey v2.0
CapsLock::Ctrl

Save the text as a plain-text file with the .ahk extension, then run the script. While it is active, pressing Caps Lock behaves as pressing Ctrl. The general form is OriginKey::DestinationKey: the key on the left is the one you press, and the key on the right is the behavior it produces. See the AutoHotkey remapping reference for syntax and behavior details.

For ordinary letters, lowercase examples such as a::b allow Shift and Caps Lock to determine letter case in the usual way. Check the key names and syntax against the AutoHotkey version you have installed; v1 and v2 scripts are not interchangeable in every respect.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.

Swap two keys instead of remapping one

A single line changes only the key on its left. To make A produce B and B produce A, define both directions:

a::b
b::a

With only a::b, pressing A produces B, but pressing B still produces B. The second line is what makes the mapping a two-way swap.

Rank #2
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites

Run, test, and change the script

  1. Create the script: Put the version directive and remap lines in a plain-text .ahk file.
  2. Run it: Launch the script, then test the remapped key in a harmless text field before relying on it in other applications.
  3. Adjust it: Edit the remap and reload or restart the script as appropriate for your installed version.
  4. Turn it off: Exit the running script to stop its remappings.

AutoHotkey remaps are active only while the script is running. Installation and automatic startup steps can vary; check the official AutoHotkey site for current setup and launcher guidance rather than assuming a particular startup procedure.

Apply a remap only in a particular window

Use #HotIf to make a remap conditional on the active window. This example limits a::b to a window whose class is Notepad:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*
#Requires AutoHotkey v2.0
#HotIf WinActive("ahk_class Notepad")
a::b
#HotIf

The final, bare #HotIf restores the default context for remaps that follow it. The example’s window identifier is not universal: identify the class or other window details for the application you want to target before using a condition.

What to expect from a remap

  • Modifiers carry through: Held modifiers such as Ctrl or Shift generally affect the destination. For example, under b::a, Ctrl+B behaves as Ctrl+A.
  • Holding and repeating: The destination is held while you hold the source key, and remapped keys normally repeat while held.
  • Compatibility varies: Some applications and games may not handle remaps as expected. AutoHotkey implements remaps as pairs of hotkeys, with hook-hotkey and input-mode caveats; no method here guarantees support in every program or on every screen.

If a remap does not work, first check that the script is running and that its syntax and key names match your AutoHotkey version. If those are correct, the target program may intercept keyboard input in a way that prevents the remap from working as expected.

Rank #4
Sale
Logitech MX Keys S Wireless Keyboard Low Profile Fluid Precise - Graphite
  • Fluid Typing Experience: Laptop-like profile with spherically-dished keys shaped for your fingertips delivers a fast, fluid, precise and quieter typing experience
  • Automate Repetitive Tasks: Easily create and share time-saving Smart Actions shortcuts to perform multiple actions with a single keystroke with the Logi Options+ app (1)
  • Smarter Illumination: Backlit keyboard keys light up as your hands approach and adapt to the environment; Now with more lighting customizations on Logi Options+ (1)
  • More Comfort, Deeper Focus: Work for longer with a solid build, low-profile design and an optimum keyboard angle that is better for your wrist posture
  • Multi-Device, Multi OS Bluetooth Keyboard: Pair with up to 3 devices on nearly any operating system (Windows, macOS, Linux, Googlebook OS) via Bluetooth Low Energy or included Logi Bolt USB receiver (2)

AutoHotkey or PowerToys Keyboard Manager?

AutoHotkey is a script-based option; Microsoft PowerToys Keyboard Manager provides a graphical interface. Choose based on whether you need window-specific conditions, whether you want to configure mappings through a GUI, and whether you need shortcut or text remapping. Both rely on a running program or utility, and compatibility depends in part on the target application.

Consideration AutoHotkey PowerToys Keyboard Manager
Configuration Write remaps in a script. Add a mapping row in the graphical Keyboard Manager interface.
Window-specific mappings Use #HotIf to condition a remap on the active window. Different mappings for different connected keyboards are not supported; app-specific mapping behavior is not established by the cited Keyboard Manager documentation.
Shortcuts and text Not covered by the basic key-remap examples here. Microsoft documents remapping keys, shortcuts, and text.
Must remain running? Yes. The script must be running for its remaps to remain active. Yes. PowerToys must remain running in the background with Keyboard Manager enabled; Microsoft says changes take effect immediately.
Compatibility considerations Some applications and games may not handle remaps as expected. Microsoft documents limits involving reserved shortcuts, Fn, the login screen, elevated apps, games, certain keyboard APIs, and shortcut keypress order.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

PowerToys-specific restrictions

In PowerToys Keyboard Manager, create a mapping row, select the input and output, and apply it. To stop those mappings, disable the utility or close PowerToys. Microsoft’s Keyboard Manager documentation, last updated June 8, 2026, lists these restrictions:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Logitech K270 Full Size Wireless Keyboard for Windows - Black
  • All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
  • Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
  • Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
  • Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
  • Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later
  • Win+L and Ctrl+Alt+Del are reserved.
  • Fn cannot be remapped in most cases.
  • Remapping at the login screen is unavailable.
  • An elevated application may require PowerToys to run elevated as well.
  • Games and applications using certain keyboard APIs may not work well with remappings.
  • Different mappings cannot be selected for different connected keyboards.
  • Some shortcut changes depend on the order in which keys are pressed.

These are PowerToys-specific documented limits, not general AutoHotkey restrictions.

Quick Recap

Bestseller No. 1
SaleBestseller No. 3
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.34
SaleBestseller No. 5
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Logitech K270 Full Size Wireless Keyboard for Windows - Black
Plastic parts in K270 include 38% certified post-consumer recycled plastic; Eight hot keys: For instant access to the Internet, e-mail, music volume and more
$21.48

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.