Last active
February 26, 2022 16:42
-
-
Save HamousOnWheels/5ec1e45e1f2053c0edb695a806643557 to your computer and use it in GitHub Desktop.
Autohotkey function that replicates Photoshop's spring loaded keys for any key. Makes a toggle temporary if key is held, or permanent if key is tapped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Replicates spring loaded key functionality for any key | |
| SpringLoadedKey(key, timeHeld) ; parameters: hotkey that you want to send, timeout for the key to be considered held and not tapped | |
| { | |
| send { %key% } ; send first hotkey on key down | |
| keywait, %A_ThisHotkey% ; wait for key up | |
| if (A_TimeSinceThisHotkey > timeHeld) ; if key was down for more than the timeout value, | |
| { ; then on key up send the second hotkey to toggle it off, | |
| send { %key% } ; otherwise do nothing, making the toggle 'stick' | |
| } | |
| } | |
| ; Call the function with something like | |
| #IfWinActive ahk_exe Photoshop.exe | |
| x::SpringLoadedKey("x", 500) ;spring loaded key for switching btw foreground and background colours | |
| ; set the timeout value as required. I believe Photoshop's is 500 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment