 	y := y * factor
 	MouseMove, x, y, 0, R
 }
+
+;ArrayJoin( sep, ary ) {
+;    for index, value in ary
+;		MsgBox % index
+;        ;str .= value . sep
+;	MsgBox % str
+;    return SubStr( str, 1, -StrLen(sep) )
+;}
 
 ; Handle the keydown for each of the mouse movement directions
 ; TODO: Maybe a way to simplify this?

; http://unlicense.org/ - public domain statement
; Version 0.1: 11/3/2011

#SingleInstance force

; Use either the embedded icon in a compiled .exe,
; or a separate .ico file when running the .ahk script.
iconPath := RegExReplace( A_ScriptFullPath, "i).ahk$", ".ico" )

; Set up the tray icon and menu
Menu, Tray, Icon, %iconPath%
Menu, Tray, Tip, JKLmouse
Menu, Tray, Add
Menu, Tray, Add, About JKLmouse, MenuAbout

; Display tray balloon
; TODO: more useful content?

; Hotkey repeat count for acceleration
repeat := 0

SetKeyMap( "Arrows", "NumPad", "IJKL", "ESDF" )
;SetKeyMap( "Arrows", "NumPad", "HJKL", "WASD" )

;MsgBox % keyMap

SetAllKeys( true )

return

SetKeyMap( keys* ) {
	global keyMap, keyMaps
    for index, value in keys
        keyMap .= keyMaps[value] . " "
    return SubStr( str, 1, -StrLen(sep) )
}

SetAllKeys( on ) {
	; Each of these modifier keys enables the same set of JKLmouse hotkeys
	SetKeys( on, "CapsLock" )
	SetKeys( on, "~LButton" )
	SetKeys( on, "~RButton" )
	SetKeys( on, "~MButton" )
	SetKeys( on, "~XButton1" )
	SetKeys( on, "~XButton2" )
}

; Set up or remove all the hotkeys for a specific modifier key
SetKeys( on, mod ) {
	global keyMap
	Loop, Parse, keyMap, %A_Space%
	{
		StringSplit map, A_LoopField, ~
		SetKey( on, mod, map1, "Mouse" . map2 )
	}
}

; Set up or remove one hotkey by combining the modifier and key names.
; Take the specified action on key down,
; and always stop acceleration on key up.
SetKey( on, mod, key, action ) {
	keydown = %mod% & %key%
	if( on ) {
		Hotkey %keydown%, %action%
		Hotkey %keydown% UP, StopAcceleration
	}
	else {
		Hotkey %keydown%, Off
		Hotkey %keydown% UP, Off
	}
}

; Move the mouse the specifed x and y distances, both scaled by the
