Skip to content

Commit

Permalink
Improve fix for #3
Browse files Browse the repository at this point in the history
The `.down()` method no longer automatically takes care of checking if the
timeout has passed. Instead such a check is sent as a parameter. Now the
`Dual.Key` class no longer needs to reference `Dual`, and unnecessary
{downKey down} won't be sent.
  • Loading branch information
lydell committed Jul 15, 2013
1 parent a2f7736 commit 9cddc83
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dual.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ class Dual {

isDown := false
subKeysDown := {}
down(forceDown=false) {
down(sendActualKeyStrokes=true) {
if (this.isDown == false) { ; Don't update any of this on OS simulated repeats.
this.isDown := true
this._timeDown := A_TickCount
}

; Skip the for loop below, which actually sends the key(s), if the timeout hasn't
; passed, in order to support modifiers that do something when released, such as the alt
; and Windows keys. `forceDown` is used by the comboKeys.
if (not forceDown and this.timeDown() < Dual.timeout) {
; In order to support modifiers that do something when released, such as the alt and
; Windows keys, it is possible to skip the for loop below, which sends the actual key
; strokes.
if (not sendActualKeyStrokes) {
return
}

Expand Down Expand Up @@ -256,7 +256,8 @@ class Dual {
upKey.send()
upKey.alreadySend := true
} else {
downKey.down(true) ; Force down the downKey, in case the timeout hasn't passed.
; Force down the downKey, in case the timeout hasn't passed.
downKey.down(downKey.timeDown() < this.timeout)
downKey.combo := true
}
}
Expand Down Expand Up @@ -294,7 +295,10 @@ Dual_keydown:
return
}

downKey.down()
; Only send the actual key strokes if the timeout has passed, in order to support modifiers that
; do something when released, such as the alt and Windows keys. The comboKeys will force it
; down, if the are combined before the timeout has passed.
downKey.down(downKey.timeDown() >= Dual.timeout)

return

Expand Down

0 comments on commit 9cddc83

Please sign in to comment.