While my mapping isn't final, I wanted to share the technique, since it works better than any other I've tried, and I've tried a bunch. Can't tell you how many times I've looked through the forums and came close but been unsatisfied in one way or another.
I'm using the space bar as my modifier, which has its advantages and disadvantages. The point of the technique isn't the key you choose as the modifier, however, but how it behaves.
Here's what I wanted:
[*:ww137etl] Works for (just about) any key
[*:ww137etl] If the key is pressed without modifying another key, it sends the regular keystroke
[*:ww137etl] If the key modifies another key, the regular keystroke is not sent
[*:ww137etl] The modifier doesn't interfere with any other modifiers also pressed
[*:ww137etl] Reliable and stable
[*:ww137etl] The key remapping syntax can be used to define the effect of the modifier
This last one was a tough one to get, because many of the other techniques rely on conditionals within each hotkey, which ends up being a ton of code.
I picked up on the Autohotkey_L #If directive used in some of the other posts for doing this. I also relied on some of the techniques mentioned in the hotkey page of the documentation.
Here's a sample that uses the space bar to turn i, j, k and l into arrow keys:
; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <[email protected]> ; ; Script Function: ; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder) ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. Space & F1::Return ; Mentioned in the hotkeys docs for UP *Space::Send {Blind}{Space} ; Send it explicitly when no other key is pressed before letting go, including any modifiers being held #If GetKeyState("Space", "p") ; Autohotkey_L directive for enabling following mappings when key is physically down j::Left l::Right i::Up k::Down #If
This seems to work for me better than other solutions I've tried, and has the benefit of being short and sweet. Hopefully it's useful to someone else as well.
To substitute any other key as the modifier, just choose that key and put it where the four references to space are instead.
The drawback to this method (or any other I've seen) is that you lose the autorepeat function for the key in question. This is a sacrifice I was readily willing to make.
For space in particular, that might be an issue for some, but it's mitigated for me by the fact that I use programming editors that allow using multiple spaces when you hit tab, so I don't need the ability to hold down the space bar to generate lots of spaces. YMMV.
Ted