Skip to content

Commit 1d26b85

Browse files
committed
Merge branch 'master' of https://github.com/evilC/TapHoldManager
2 parents f5d4452 + 44a4ecf commit 1d26b85

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

README.md

+21-7
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ In either case, `taps` holds the number of taps which occurred.
4747
For example, if I double-tap, `IsHold` will be false, and `taps` will be `2`.
4848
If I double-tapped and held on the second tap, then on press the function would be fired once with `IsHold` as true, taps would as `2` and state as `1`. When the key is released, the same but `state` would be `0`
4949

50-
## Syntax
51-
```
52-
thm := new TapHoldManager([ <tapTime := -1>, holdTime := -1, <maxTaps := -1>, <prefix := "$"> ])
53-
thm.Add("<keyname>", <callback (function object)>)
54-
```
50+
## Instantiating TapHoldManager
51+
`thm := new TapHoldManager([ <tapTime := -1>, holdTime := -1, <maxTaps := -1>, <prefix := "$">, <window := ""> ])`
5552

5653
**tapTime** The amount of time after a tap occured to wait for another tap.
5754
Defaults to 150ms.
@@ -62,18 +59,35 @@ Defaults to infinite.
6259
Setting this value to `1` will force the callback to be fired after every tap, whereas by default if you tapped 3 times quickly it would fire the callback once and pass it a `taps` value of `3`, it would now be fired 3 times with a `taps` value of `1`.
6360
If `maxTaps` is 1, then the `tapTime` setting will have no effect.
6461
**prefix** The prefix used for all hotkeys, default is `$`
62+
**window** An AHK [WinTitle](https://www.autohotkey.com/docs/misc/WinTitle.htm) string that defines which windows the hotkey will take effect in
63+
For example, to make Hotkeys only work in Notepad, you could use:
64+
`thm := new TapHoldManager(,,,,"ahk_exe notepad.exe")`
6565

6666
You can pass as many parameters as you want.
6767
`thm := new TapHoldManager()`
6868
`thm := new TapHoldManager(100, 200, 1, "$*")`
6969

70-
When specifying parameters, you can use `-1` to leave that parameter at it's default.
71-
For example, if you only wish to alter the `prefix` (3rd) parameter, you could pass `-1` for the first three parameters.
70+
When specifying parameters, you can omit the parameter (or use `-1`) to leave that parameter at it's default.
71+
For example, if you only wish to alter the `prefix` (3rd) parameter, you could do:
7272
`thm := new TapHoldManager(-1, -1, -1, "$*")`
73+
Or
74+
`thm := new TapHoldManager(,,, "$*")`
7375

76+
## Adding Hotkeys
77+
`thm.Add("<keyname>", <callback (function object)> [,<tapTime := -1>, holdTime := -1, <maxTaps := -1>, <prefix := "$">, <window := "">])`
7478
When adding keys, you can also add the same parameters to the end to override the manager's default settings
7579
`thm.Add("2", Func("MyFunc2"), 300, 1000, 1, "~$")`
7680

81+
## Enabling or Disabling Hotkeys
82+
Hotkeys can be disabled by calling `PauseHotkey` and passing the name of the key to pause:
83+
`thm.PauseHotkey("1")`
84+
85+
Hotkeys can be re-enabled by calling `ResumeHotkey` and passing the name of the key to resume:
86+
`thm.PauseHotkey("1")`
87+
88+
Hotkeys can be removed by calling `RemoveHotkey` and passing the name of the key to remove:
89+
`thm.RemoveKey("1")`
90+
7791
## Logic Flowchart
7892
(Note that the firing of the function on key release during a hold is omitted from this diagram for brevity)
7993
![flowchart](LogicFlowchart.png)

0 commit comments

Comments
 (0)