Keyboard Remapping: Part III – SharpKeys

Given “part II” of this Keyboard Remapping bit, it became obvious to me that I would be spending more and more time hacking the Registry, just to remap keys, especially with my ThinkPad. Even though IBM gave me an application to change keys, and Microsoft gave me IntelliType utilities, both meant that drivers would have to be loaded, and that sorta irked me for some reasons… call it a throw back to the days of TSR programs, but I get “itchy feet” when I have to leave unnecessary drivers loaded.

The nice thing about this is that I’m not doing much of anything; I’m just exposing work that Microsoft has done for us. As should be no surprise to anyone by now, there’s a Registry hack that allows you to map one key to another within Windows 2000, Windows XP, and Windows Server 2003. Nice thing about that is that there’s no extra drivers that need to be loaded – it’s built into Windows. Bad thing about that is that it’s a bit of a bugger, finding the scan codes for the keys you want to remap, and then getting all of the values right. Not impossible, given that it’s been done before, but it is a pain in the ass.

Enter SharpKeys. It’s an interactive Registry hack and it’s simple. Open SharpKeys and it reads in the current value of the “magic” Registry value. Make whatever changes you want and you can write this back out to your Registry. Reboot (or log out and back in – that sometimes works) and you’re done: the remapped keys should be working now.

Should be working? Yeah, should be working. Some of the newer keyboards have funky extra keys and while I tried to get a bunch of them, I’m pretty sure that they all won’t work – I’m hoping for most of them to work. If you know of a special key’s code that is on many keyboards, please e-mail me with it – I can add it in future releases… of course, if you know the scan code, you probably have no need for this hack in the first place!

Beyond that, here’s the obvious: Use this at your own risk! As much as I’d love to write perfect code, I know that I never do and this is something that’s in a very “dangerous” part of your computer. OK, so my code is 99.44% accurate most times, but still. [insert gacking sound here] If you aren’t comfortable with it, don’t use it, especially when it’s in beta! In spite of having said this, I don’t expect many problems with it – I’m just trying to be honest with everyone out there. Also you must have version 1.1 of the .NET Framework installed for this to be used. Lastly, I’m told that this Registry hack only works with Windows 2000, Windows XP, and Windows Server 2003 – if anyone tries it and finds that it works on 95/98/Me, please let me know.

And finally, here’s the bits you’ve been reading all this for:

Main page: SharpKeys information

Download: SharpKeys

Read: SharpKeys FAQ

Screenshots: 1 | 2

34 thoughts on “Keyboard Remapping: Part III – SharpKeys”

  1. Hah – that’s already there, if you go into the registry editor… neat little .REG comes out that can be put anywhere.

  2. Like you, I must say I hate loading a driver just to remap a few keys – your sharp keys program is quite nice I must say.

    I was just wondering if you had ever looked at maybe doing a SharpMouse? I generally remap the navigate buttons on my mouse to copy/paste (I am a coder like you) and I love it, but hate loading the driver to do it. Any ideas if this is feasible?

  3. Got me – if Windows has a registry key for it, than sure… the only reason why this works without a driver is that Windows has an internal – but non-exposed – method of doing this… the only thing I do is expose it.

    Wonder if Longhorn is going to keep this in here. I should load up the PDC bits and see, when I get a moment.

  4. Thought that more than that would cause a problem – besides, I’m not sure what the limit within XP is… thought 16 would be a good limit.

    Anyone know the maximum keys for Scancode Map?

  5. AH-HAH! I forgot the damned F-lock key. This poses a problem indeed. As that article posts, the F-lock key can’t be controlled – it’s a hardware state function. So what it looks like the fix here is, is 19 remaps between the Fn keys and the F-locked Fn keys. Which are very particular per keyboard. Which means that I’m probably going to pretend I don’t have a Microsoft Natural Keyboard on my desk and move on… *whistles*

    Anyway, this proves that more than 16 is allowed. I guess I can raise that limit to 101… well 104 or even 125 these days. Imagine if you remapped the entire keyboard to Q? hah!

  6. Actually – I take that back. Seems that only two of the keys are different between the office and non-office keyboards. I’ll add it for Beta 2 (tonight or tomorrow).

  7. very nice work Randy!!

    Would it be possible to change the way of selecting the “From”-key to instead of selecting a key from a list, pressing a key to change? This way you wouldn’t have to worry about language differentials (assuming the app can capture the scancode which was pressed). I myself am from Sweden and I miss some of our country-specific characters ().

  8. Already looked into that just after this beta was out there. Sadly, no – for whatever reason KeyDown/KeyUp are NOT returning the correct information: both shift keys come in as “Shift” rather than left/right. Keys like IBM’s Back/Forward both come in as either FF or 00. Other keys don’t come in at all. I even thought of putting in a “custom” value but I’m afraid of what people might do to themselves (and then expect me to fix!).

    I am working on something that’s an optional view to select keys, but the “press and capture” mode will have to wait until things work better from within C#… I’ll be checking it out when VS.NET 2004 comes out, though.

  9. this sounds like the perfect little app to solve my problem. but i ain’t touching any .NET stuff, not even with a LONG stick :( anybody know of other apps that do the same thing but don’t require anything “extra” that i need to download?

  10. Probably, but what possible reason could you have for not installing a set of runtime libraries that don’t hurt a PC at all? I mean, that’s one of the most ridiculous notions I’ve heard today, if not all week. :)

    If you’re so anti-.NET, edit the registry yourself with the instructions included in this section…

  11. Hey Randy,

    I read through your FAQ’s and all comments but still I would like to add this. Maybe its just my keyboard but SharpKey could not recognise “PrtScn / SysRq” – Print Screen button. I should add that this is few of the least used buttons. Also I did not see a scan code for this button in SharpKeys.

    Also in the last comment you talked about the instruction manual for editing the registry. I would like to get my hand on that.

    Thanks

    Krish

  12. Well, as per the other posts on the site, PrtScn is something that sends three code values, not two, so it’s not really possible to trap correctly. Windows is geared for a 2 code combo when remapping – especially since that’s what’s doing the remapping.

    As for more information on the product, plz take a look at http://www.randyrants.com/sharpkeys/ for more recent information – this post is almost a year old so I don’t remember what I was talking about!

  13. Randy,

    Is there a way to map one key to two keys that are simultaneous hit (WINDOWS KEY+D, WINDOWS KEY+M) or three keys (WINDOWS KEY+SHIFT+M)?

    Thanks,

    Matt

  14. Nope. As per all of the posts and FAQ’s whole keys can be remapped – not modifiers for a key. You’d have to talk to the ppl that make the application you want to control to process Win+key.

  15. I just want to point out that .NET information is just another way to map out your movements and for Microsoft to record your “habits” (I use that loosely), it makes sense for the paranoid person to not download .NET. I do not use .NET because of this, anything you do is availible for your government to monitor. I wanted to remap my keyboard (I have some extra keys that the driver provided does not work under 2k or XP), but I don’t need to have Microsoft informing the government that I have extra keys specific to my keyboard.

    Please consider writing this program in a more compatible language, assembly would (mostly) be cross platform (XP, 2000, 98, ME, 2003) and be small, reading scancodes directly and altering the registry more reliably.

  16. I’ll be blunt. What the fuck are you talking about?

    And no, I will not re-code this because you’re paranoid about your computer habits… what are ya doing that makes you so very worried? Nor am I going to debate that .NET tracks your movements for government official – it’s completely preposterous – and if you’re that worried about having your tracks tracked, you have a few other things to worry about first, before even thinking about Frameworks and Runtimes tracking movements. First disconnect from the Internet, then disconnect any keyboard cables, b/c they COULD have one of those tracking devices… then you should always wipe every drive you touch with a Government class formatter, and then stop using a computer, for obviously reasons. Then invest in a safe and/or a shedder to protect all of your important documents.

    If you’re that deep in computer know that you KNOW all about all of this tracking in the .NET framework and you positively KNOW that writing this in a different language would be easy and cross platform, I would honestly think that you would have been smart enough to read the rest of the posts about SharpKeys… or at least the FAQ. It’s nothing more than a front end that exposes a registry key, and it’s a key that’s only supported in 2000, XP, and 2003. Windows does the key remapping, not SharpKeys. So – just as an FYI – if Windows doesn’t see the keys you’re looking to remap, SharpKeys won’t help – this is covered in about a dozen places on this post and all of the other SharpKeys posts.

    In fact, now that I’ve re-read the babble that you’ve posted about the government wanting to konw that you have extra keys, I’m ending this here before I *really* get insulting.

  17. JON if you are worried about the goverment looking at what you do you are screwed when it comes to windows windows is prone to spywear and every thing else that tracks habbits if you want to remap your keys and not have to do it randys way get linux kill 2 birds with one stone.

    Randy,

    I am trying to figure out if there is a program or way to bind ctrl+c ect to some keybord function keys mainly becuase i do a lot of cut and paste and print getting annoying to have to go threw so much just to cut and paste.

  18. And linux can still have keys tracked with hardware, which is what I think he’s concerned about. So I’m missing something there.

    Anyway, Windows doesn’t remap modified keys (i.e. Ctrl+C and not regular C) – it takes the entire key, so there’s nothing much I can do for ya… sorry!

  19. damn windows so frinking stupid any way i still think the program rocks nice and clean way to do it

    well you have to have the hard ware that tracks the keystokes if you a end user i think you would notice a extra peace of hardware thats attached to your computer.

  20. Hi,

    I too prefer something else than .NET and it doesn’t have anything to do with security blahblah.

    I’m on dial upand can’t afford to dld .net runtimes.

    could you atleast considering making a package of your program with minimal subset of .net to run the program, if such is possible.

    Hey, BTW, does your program work with logitech keyboard too? I mean the enhanced keys.

    thank you.

  21. Not a chance. I mean, I’m sorry that you’re on dial up, etc., but the tool was written in .NET and that’s a requirement.

    Dunno about the Logitech Keyboard – the normal keys should work fine… the enhanced keys havea 50-50 shot. It all depends on if they are pass to Windows or not, and usually a “have to try it and see” thing.

  22. If you don’t trust .net on the internet, run it behind a firewall – a real, user controllable, hardware firewall, not Zone Alarm Free. One that lets you EDIT outgoing messages, not merely block them. Tell Microsoft you push the Q key 300 times a minute, all day, every day. Which is easy, of course, because all your keys ARE mapped to the “Q”. Right?

    If you’d rather investigate than trust, or not trust, put a couple of monitors on .net and find out what it does, and doesn’t do – for real – before getting in a flame war about it.

    I won’t install it either, but I know why, and I know the reasons are specific to my business, but then we don’t have IE, Windows Media Player, or Soundrec on our Windows computers either.

    Soundrec, you say?? THAT’s paranoid, right?

    Nope, just pragmatic. We have 8 fairly major applications we use on wave files (not necessarily the same tools for uncompressed .wav, compressed .wav, .aiff, .au, etc). We have context menus and file associations that manage this well.

    If soundrec is run, it completely hoses these associations beyond repair. And being OLE, you don’t necessarily have control over whether it is run or not. If a programmer wants to invoke the Soundrec OLE interface instead of your file association for a soundfile, you can’t stop them. Similarly with Windows Media Player. Some people find these behaviors desirable (i.e. no matter how many silly sound toys your kids download from the net, media player always “fixes” itself afterwards, which is cool if you don’t know what CoolEdit is, or who PhrozenCrew is, or why software on your computer is registered to them.)

    After a while, I got tired of re-registering my associations, even with a regfile, and decided to give up OLE sound. The only “feature” I lose is if some bozo inserts a wave file into a Word document, I have to save it separately to hear it.

    I’m certainly not going to go around complaining that Soundrec ruins people computers (though it could cost us a couple of thousand dollars a shot before we worked out the regfile to fix it each time), but if I need to use software that tries to invoke Soundrec instead of trusting me to manage wave files, I’m going to complain to the author too.

  23. Hi, do you think you could add into your program the functionality of remapping mouse keys as well?

    It doesn’t seem there is any free remapper that can do this correctly.

  24. I’d consider it, but I’m not mapping the keys on the keyboard itself – I’m just exposing what Windows already does… it’s not exposed through anything but the registry. For mice buttons… that should have a driver, depending on the mouse you own. I know the IntelliPoint driver remaps buttons – can’t speak for Logitech or Kensington or the rest.

  25. Woah fast reply. You’ll consider it? I’ve been trying to remap a mouse key for a game which doesn’t allow you to remap the mouse keys. So like, make ‘Mouse2’ activate the keyboard ‘R’ and make ‘R’ activate ‘Mouse2’ etc.

Comments are closed.