Skip to content

Commit

Permalink
Add defaults.ahk
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Nov 17, 2013
1 parent 9663fae commit bd1eb3d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 24 deletions.
39 changes: 21 additions & 18 deletions sample.ahk → defaults.ahk
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
SendMode Input
#NoEnv
#SingleInstance force


#Include dual.ahk
dual := new Dual


;;; dual-role keys

*Space::
*Space UP::dual.combine("RCtrl", A_ThisHotkey)


;;; comboKeys

*a::
*b::
*c::
Expand Down Expand Up @@ -73,7 +56,7 @@ dual := new Dual
*Insert::
*Delete::
*Backspace::
; *Space:: ; Commented out since space is set as a dual-role key above.
*Space::
*Enter::
*Tab::
*F1::
Expand All @@ -90,3 +73,23 @@ dual := new Dual
*F12::
dual.comboKey()
return

*LShift::
*LShift UP::
*RShift::
*RShift UP::
*LCtrl::
*LCtrl UP::
*RCtrl::
*RCtrl UP::
*LAlt::
*LAlt UP::
*RAlt::
*RAlt UP::
*LWin::
*LWin UP::
*RWin::
*RWin UP::
dual.modifier()
return

70 changes: 64 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ git (`git clone https://github.com/lydell/dual.git Lib/dual`) or, preferably, ad
(`git submodule add https://github.com/lydell/dual.git Lib/dual`).

Then include the script into the AutoHotkey file you chose. That exposes the `Dual` class, which is
used for configuration and setting up your dual-role keys.
used for configuration and setting up your dual-role keys. Example:

; Recommended, but not required:
SendMode Input
#NoEnv
#SingleInstance force

#Include <dual/dual>
dual := new Dual

#Include <dual/defaults>

#If true ; Override defaults.ahk. There will be "duplicate hotkey" errors otherwise.

; Steve Losh shift buttons.
*LShift::
*LShift UP::dual.combine(A_ThisHotkey, "(")
Expand All @@ -40,7 +49,9 @@ used for configuration and setting up your dual-role keys.
*j::
*j UP::dual.combine("RWin", "n")

You can use [sample.ahk] as a starting point. It works out of the box—just run it!
#If

*ScrollLock::dual.reset()



Expand Down Expand Up @@ -274,8 +285,6 @@ _comboKeys_ are keys that enhance the accuracy of the dual-role keys. They can b
*a::
*a UP::dual.comboKey()

See [sample.ahk] for a starting point.

Also note that the settings can be set per dual-role key. See the `combine()` method. This let's you
fine-tune specific keys. After all, our fingers and the possible key combinations of the keyboard
are all different.
Expand Down Expand Up @@ -305,6 +314,54 @@ dual thought that I accidentally made a combination. After I while I found a bal



defaults.ahk
============

To make it easier for you, most keys of the en-US QWERTY layout are turned into comboKeys in the
file [defaults.ahk]. And `dual.modifier()` is run on all modifiers. Before including it, there are a
few things to notice.

- It assumes your `Dual` instance to be called `dual`.
- It sets up hotkeys, so including it will end the auto-execute section.
- You must wrap your hotkeys in `#If conditions`:s to override the defaults. You will get "duplicate
hotkey" errors otherwise.
- You can probably use it even if you don't use en-US QWERTY. For example, Dvorak and Colemak should
make no difference. sv-SE QWERTY users should be fine, but might want to add å, ä and ö as
comboKeys. And so on.

An example:

#Include <dual/dual>
dual := new Dual ; The instance is assumed to be called `dual`, so we'd better use that.

; This must be included after the above, since it ends the auto-execute section.
#Include <dual/defaults>

; Add sv-SE extra comboKeys.
*å::
*ä::
*ö::
dual.comboKey()
return

#If true ; Override defaults.ahk. There will be "duplicate hotkey" errors otherwise.

*Space::
*Space UP::dual.combine("RCtrl", A_ThisHotkey)

#If

#If settings.shift ; Using a "real" `#If` works, too, of course.

*f::
*f UP::dual.combine("LShift", A_ThisHotkey)
*j::
*j UP::dual.combine("RShift", A_ThisHotkey)

#If



Limitations
===========

Expand Down Expand Up @@ -401,12 +458,13 @@ no meaningful tests yet.)
Changelog
=========

0.5.0 (Unreleased)
0.5.0 (2013-11-17)
------------------

- Removed: The `force` option. It never really worked. (Backwards incompatible change.)
- Added: The `combinators` parameter of the `comboKey()` method, replacing the `force` option and
the old advice on combinator shortcuts.
- Added: defaults.ahk.

0.4.3 (2013-11-13)
------------------
Expand Down Expand Up @@ -502,7 +560,7 @@ License
[key list]: http://www.autohotkey.com/docs/KeyList.htm
[Limitations]: #limitations
[MIT Licensed]: LICENSE
[sample.ahk]: sample.ahk
[defaults.ahk]: defaults.ahk
[test/dual.ahk]: test/dual.ahk
[wikipedia-dual-role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys
[YUnit]: https://github.com/Uberi/Yunit

0 comments on commit bd1eb3d

Please sign in to comment.