News for hackers. Stuff that matters.
Re:Toward a More Useful Keyboard by mrandish on Wednesday June 14, 2023 @02:58PM (#36330851)
> Caps Lock can be a useful feature.

Being a Windows user I have an AHK script I run on every PC I work on regularly. It remaps Caps Lock into a special modifier key but does so in a conditionally timed way which keeps Caps Lock working as it normally does as an on/off toggle - but only when pressed and released by itself. If I use Caps Lock like a modifier key by holding it down and hitting another key simultaneously then Caps Lock works like a modifier - which I use to remap other home row keys like arrows etc.

This works transparently while giving me another very useful modifier key right on the home row without giving anything up. It's especially useful on laptops where I don't have extra modifier keys like my custom desktop keyboards but I now use it everywhere. Here's the relevant chunk of AHK script:

  CapsLock::
   KeyWait, CapsLock                      ; wait for Capslock to be released
   KeyWait, CapsLock, D T0.2              ; and pressed again within 0.2 seconds
   if ErrorLevel
   return
    else
   if (A_PriorKey = "CapsLock")
      SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On" 
  return

  *CapsLock::
  return

  #If, GetKeyState("CapsLock", "P")   ;Your CapsLock hotkeys go below
   i::Send {Up}
   j::Send {Left}
   k::Send {Down}
   l::Send {Right}
   m::Send {End}
   u::Send {Home}
   y::Send {PgUp}
   n::Send {PgDn}
   h::Send {BS}
   `;::Send {Delete}
   -::Send {–} ; Alt+Minus = En dash
   =::Send {—} ; Shift+Alt+Minus = Em dash
   a::^a
   Space::Enter
   q::PrintScreen
   r::F5
   s::Browser_Back
   d::Browser_Forward 

  Capslock & LButton::WindowMouseDragMove()
  Capslock & RButton::WindowMouseDragResize()

There are no comments on this comment yet.