Two shortcuts for the same key
Two shortcuts for the same key
For example, the F2 key executes the ctrl v shortcut, and the F2 + F3 shortcut opens the download folder, but when I execute F2 + F3, the ctrl v shortcut also executes first and then the download folder opens, my question is the following, how translates to that when clicking only F2 should execute only the shortcut ctrl v and when clicking F2 + F3 execute only the opening of the download folder without executing both shortcuts at the same time when you click F2
-
- Posts: 26
- Joined: 16 Nov 2020, 14:47
- Contact:
Re: Two shortcuts for the same key
For such a simple case (two key combos->two actions), I would use something like the following:
You can also use #HotIf with GetKeyState (and for more complex combinations, I would recommend it), but things like key-press order can be more important in those cases.
See the Custom Combinations section of the Hotkeys docs for more examples: https://lexikos.github.io/v2/docs/Hotkeys.htm#combo
Code: Select all
F2::{
;;Add a slight delay before the check for F3's keystate
;;(This improved consistency for me, personally)
sleep 100
if GetKeyState("F3") {
msgbox("F2 & F3 pressed.")
} else {
msgbox("F2 pressed.")
}
}
You can also use #HotIf with GetKeyState (and for more complex combinations, I would recommend it), but things like key-press order can be more important in those cases.
See the Custom Combinations section of the Hotkeys docs for more examples: https://lexikos.github.io/v2/docs/Hotkeys.htm#combo