How can I remap a keyboard key?

277,894

Solution 1

Here is a good article from Howtogeek about using a utility called SharpKeys:

##Map Any Key to Any Key on Windows 10, 8, 7, or Vista If you are tired of the way certain keys on your system work, such as the Caps Lock key, you can re-map them to function as a different key by using a registry hack. But there should be an easier way, right?

This is where SharpKeys comes into the picture: It’s a small utility that will let you easily map one key to another key easily, or even turn the key off, without having to enter the registry at all.

For instance, I used the key mapping to just turn off my Caps Lock key, since I never use it.

image
(source: howtogeek.com)

You can click the Add button to bring up the Add New Key Mapping dialog, where you can either select the keys to map from the lists, or just click the Type Key button and press the key manually (which I find much more intuitive)

image
(source: howtogeek.com)

Once you are done, click the Write to Registry button and you’ll be told to log off or reboot for the changes to take effect.

image
(source: howtogeek.com)

If you want all the technical details on how the registry keys work, you can read about how to map keys using registry hacks.

Link for reference

Solution 2

Using Microsoft Keyboard Layout Creator here without problems. For switching modifier keys I would suggest a registry hack or an application that changes the registry for you, do not use a pure software remap like AutoHotkey as those solutions don't work for every application.

Another solution is to get a replacement key in case you really can't insert the key back in your laptop, have you tried a search for 'broken laptop key'?

Solution 3

You can use Microsoft's Keyboard Layout Creator.
This will even allow you to add extra functionality to your keyboard, such as changing a key into a dead key (e.g. ~), add extra mappings (e.g. altgr+c ->ç), etc.

In order to edit the special keystrokes, like ctrl+FOO, you might need to edit the .klc file manually.
You can find instructions by @Senseful in https://superuser.com/a/172993/157884 :

You need to modify the .klc file manually.

Basically you just modify the VK_ column to match the value in column 1.

So for example if you want to bind L to N, you would create the keyboard as you normally would in KLC. Then you would open the KLC file in a text editor. Find the value L in the VK_ column, and switch it to an N.

For more information, I wrote the complete steps on my blog.

Warning: incomplete support for key bindings in some applications

However, be warned that some applications might not take those special keystrokes properly.

As an example: with my particular configuration, pressing altgr+a in DotA2's teamchat will erase the text — instead of adding an ã like in other applications.

Solution 4

I have Genius KB-G235 USB keyboard (HID) and WinXP SP3. Neither of applications in previous answers didnt work for me. (Because working with PS/2 codes or not (fully) with XP).

I tried HotkeyP (freeware) http://petr.lastovicka.sweb.cz/others.html and this works! Just add action for key and its done. (After assign new action isn't default action executed.)

Solution 5

Keyman Desktop - You can even create your own custom keyboards with Keyman Developer. With keyboards for over 1000 languages, Keyman Desktop lets you type in your language even when Windows doesn’t.

Share:
277,894

Related videos on Youtube

Kasper Grubbe
Author by

Kasper Grubbe

Just another djork trying to ply his art in this mad mad world. Tech stack I prefer to use: Laguage: C# / .NET Core / ASP.NET Core Editors: Visual Studio / VS Code Persistence: RavenDB, SqlServer (MSSql or Postgres) Source control: Github Containers: Docker & trying to learn K&'s Cloud Platform: Azure Caching/CDN: Cloudflare Finally: A Tauntaun sleeping bag is what i've always wanted spaces > tabs

Updated on September 17, 2022

Comments

  • Kasper Grubbe
    Kasper Grubbe over 1 year

    One of my laptop's keys has fallen off. Is there any way I can remap another key to serve as that key? I'll 'sacrifice' the other key because I never use it.

    • Colonel Panic
      Colonel Panic almost 11 years
      Scroll lock: Why are you looking at me?
    • Lilienthal
      Lilienthal over 8 years
      This question covers permanently remapping keys. Most answers are based on a registry edit requiring a reboot. For ways to remap keys without a restart, swapping keys with each other, or swapping for specific applications, see this question: Remapping keyboard keys for specific applications
    • john v kumpf
      john v kumpf almost 6 years
      @harrymc the vlaurie.com link is dead (now hosted by ParkLogic)
    • harrymc
      harrymc almost 6 years
      @johnvkumpf: There are heaps of such articles. Most dead links can still be found on the Wayback Machine. For this one see here.
    • Alaa
      Alaa over 4 years
      SharpKeys (free download from authoritative source): github.com/randyrants/sharpkeys/releases
  • John T
    John T over 14 years
    For simple remapping this is the way to go, no need to write a full blown autohotkey script. I swear by AHK don't get me wrong, but thats more for keyboard combinations rather than simple remapping.
  • Nam G VU
    Nam G VU over 13 years
    Very easy to use - would be more lovely to be able to toggle the keys (enable/disable it) without deleting anything
  • James Broadhead
    James Broadhead almost 13 years
    This is th best solution I have found - unlike AutoHotKey and Keytweak, I can modify the characters generated with modifiers, without changing the unmodified behaviour. Now I can get ( and ) without Shift, 9 and 0 are unaffected! :D
  • Colonel Panic
    Colonel Panic over 8 years
    Do I have to run the app all the time, or is the change permanent?
  • Ian Jamieson
    Ian Jamieson over 8 years
    The HowToGeek registry hack link above is perfect for doing this without software -- but the scancode link in said article is dead. Here's a live (as of today) one: msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
  • Yuuza
    Yuuza about 8 years
    But why all of this if something like ScrollLock::LControl is just enough for the remapping?
  • Jp_
    Jp_ about 8 years
    Sorry, I really could simplify, but I wanted to show the power of the tool. With this script you don't need to sacrifice keys, you just need to have a modifier key and have a second function for one key.
  • Avatar
    Avatar over 7 years
    I am using two different USB keyboards the same time, working multilingual. One of my keyboards has a disturbing layout for INS, END, DEL, ... that I wanted to change. Needing to reboot everytime I change the keyboard is not a solution. Then probably Autohotkey is. Need a simple on-off-switch. Or I just get used to SHIFT + NumKeys...
  • Anton Daneyko
    Anton Daneyko over 7 years
    It seems my custom mapping was reset after a Windows update. Did anyone had this issues?
  • agaragaragar
    agaragaragar over 7 years
    Seems like this doesnt support remapping to Alt Gr.
  • Jukka K. Korpela
    Jukka K. Korpela about 7 years
    The Keyman software is becoming free after SIL International bought it. This makes it a more interesting choice than before. (Few people would buy software to do just a simple mapping of a key for personal use.)
  • David Sopko
    David Sopko over 5 years
    For some applications that (presumably) are listening to keydown events it is also necessary to also remap keyboard scan codes. It's a nice solution because it's built into windows and you can use the windows shortcuts.
  • stiv
    stiv over 4 years
    The only problem is that it requires .NET Framework 2.0 - if you install it to run the keyboard layout creator, make sure you uninstall it after!
  • Black Chase
    Black Chase over 2 years
    I wanted to interchange my backspace and caps lock. This method doesn't work for me.