Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've remapped my Caps lock key to Ctrl+Alt+Shift based on this superuser answer

; Caps lock becomes ctrl+alt+shift
*CapsLock::
  SetKeyDelay -1
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

*CapsLock up::
  SetKeyDelay -1
  Send {Blind}{Ctrl Up}{Alt Up}{Shift Up}
return

And then in order to get Vim style navigation, I've attempted to remap hjkl to my arrow keys. I tried several approaches which did not work at all. I've settled on the following approach because it works for single key presses. But when I hold down, for instance, Caps lockJ in Eclipse, the CtrlAltJ keyboard shortcut fires instead of simply going down a line. It only goes off for automatic keyboard repeats, never for the original key press.

^!+h::
  Send {Left}
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

^!+j::
  Send {Down}
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

^!+k::
  Send {Up}
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

^!+l::
  Send {Right}
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

Scrolling down 20 lines by hitting J 20 times is too tedious. Does anyone have a solution, or am I using something inappropriately? I have some other commands mapped to Caps lock and CapslockWin (technically mapped to ^!+ and ^!+#), so fixes would preferably not break those. For instance:

; Caps lock + i becomes escape
^!+i::
  Send {Escape}
  Send {Blind}{Ctrl DownTemp}{Alt DownTemp}{Shift DownTemp}
return

This works fine right now because I haven't had a need to hold down the Esc key. Thanks!

share|improve this question
    
Is there any particular reason why you must use Ctrl+Alt+Shift? I would think having CapsLock just toggle a variable would make this easier/simpler. –  Elliot DeNolf Dec 7 '12 at 20:21
    
I was using Ctrl+Alt+Shift because it also had the benefit of letting me set hotkeys in other programs without worrying about collision. But that wasn't working anyway with my attempt, so nothing was lost by switching to your solution below. –  Daniel Koverman Dec 10 '12 at 20:25
add comment

1 Answer

up vote 2 down vote accepted

This is a sort of alternative to what you are currently doing. I have made it so CapsLock simply toggles the variable cmd. Based upon this variable, your movement keys are enabled. Any of these keys can be held in order to repeat multiple times.

I have also provided some methods, which may be overkill for right now but may prove to be useful to you later.

*CapsLock::    cmd := 1
*CapsLock up:: cmd := 0

#if cmd
    h::Key("left")
    j::Key("down")  
    k::Key("up")    
    l::Key("right")
    n::Key_repeat("^", "left")
    p::Key_repeat("^", "right")
#if

Key(key)
{
   SendInput {blind}{%key%}
}

Key_repeat(pfx, key)
{
    SendInput {blind}%pfx%{%key%}
}
share|improve this answer
    
Thanks a lot, this solves my problem. #if and and the autohotkey method syntax are helpful to know about as well. –  Daniel Koverman Dec 10 '12 at 20:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.