AutoHotkey Community

It is currently May 26th, 2012, 5:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Half-QWERTY keyboard
PostPosted: March 29th, 2008, 6:11 am 
Offline

Joined: November 6th, 2005, 6:43 pm
Posts: 72
Half-QWERTY keyboard

Allows you to code (or do other things) one-handed, using a normal keyboard. While the spacebar is pressed, each half of the keyboard is mirrored to the other.

Code:
#SingleInstance force
#InstallKeybdHook   ; otherwise space-up tends to get dropped

; ==== keyboard configuration ====
Pair("1", "0")
Pair("2", "9")
Pair("3", "8")
Pair("4", "7")
Pair("5", "6")

Pair("q", "p")
Pair("w", "o")
Pair("e", "i")
Pair("r", "u")
Pair("t", "y")

Pair("a", semicolon := "SC27")
Pair("s", "l")
Pair("d", "k")
Pair("f", "j")
Pair("g", "h")

Pair("z", slash := "SC35")
Pair("x", period := "SC34")
Pair("c", comma := "SC33")
Pair("v", "m")
Pair("b", "n")

Pair("tab", "backspace")
Pair(dash := "SC0C", backtick := "SC29")


OneWay("capslock", "enter")   ; special case...  unmirrored=enter, mirrored=quote
Hotkey,*capslock, on
Hotkey,*capslock up, on


Pair(x, y)
{
   OneWay(x, y)
   OneWay(y, x)
}


; remap `from` to `to`  (but only when space is depressed)
OneWay(from, to)
{
   global      ; (apparently `global remap_%from%` is still invalid syntax...)

   Hotkey, *%from%,    remap_down, off
   Hotkey, *%from% up, remap_up,   off

   ;ToolTip, %from%, 0, 0      ; uncomment to find out what has to be converted to "SCnn" syntax
   remap_%from% := to

   if (remap_list != "")
      remap_list := remap_list . "`n"
   remap_list := remap_list . from
}


space::
   Loop, parse, remap_list, `n
   {
      Hotkey, *%A_LoopField%,    on
      Hotkey, *%A_LoopField% up, on
   }
   remap_capslock := "'"
   hotkeys_mirrored := 0
   return

space up::
   Loop, parse, remap_list, `n
   {
      Hotkey, *%A_LoopField%,    off
      Hotkey, *%A_LoopField% up, off
   }

   Hotkey,*capslock, on
   Hotkey,*capslock up, on
   remap_capslock := "enter"

   if (hotkeys_mirrored == 0)
      SendPlay,{space}
   return


remap_down:
   remap_from := SubStr(A_ThisHotKey, 2)
   remap_to := remap_%remap_from%
   ; the exact equivalent of remapping, see http://www.autohotkey.com/docs/misc/Remap.htm#SendPlay
   SetKeyDelay -1
   Send {Blind}{%remap_to% DownTemp}

   hotkeys_mirrored := hotkeys_mirrored + 1
   return

remap_up:
   remap_from := SubStr(A_ThisHotKey, 2, -3)   ; "*enter up" => "enter"
   remap_to := remap_%remap_from%
   ; the exact equivalent of remapping, see http://www.autohotkey.com/docs/misc/Remap.htm#SendPlay
   SetKeyDelay -1
   Send {Blind}{%remap_to% Up}
   return


Last edited by interiot on March 29th, 2008, 7:46 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2008, 8:23 pm 
nice script....


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSNbot Media and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group