I'm developing a Delphi XE7 multi-platform application and want to use some hotkeys / shortcuts.
TActionList
, TMainMenu
and TMenuBar
all have properties to assign ShortCuts.
I am using an shortcut to add a new TTabItem
on a TTabControl
. That ShortCut is Ctrl + T.
So if the user presses Ctrl + T a new tab is added on said TTabControl
- working correctly.
However if the user keeps holding down those 2 keys multiple tabs are created as well.
The shortcut event is triggered as long as the user keeps holding down those keys.
Adding a new tab is only an example. I am using multiple shortcuts that I only want to trigger once.
Is there any way to only trigger a shortcut event once?
I tried timers / waiting a specific amount of time. But that causes problems if the user wants to quickly perform 2 hotkeys.
Thanks for reading and I appreciate all help.
Here is an example of how to solve this using Timer so that it doesent block users from using multiple different actions in a row. The speed for using of the same action depends on your configuration but is limited by system Key Autorepeat delay interval. See in code comments.
NOTE: Set timer interval to 1 ms. And don't forget to set ActionCooldownValue to be greater than system key autorepeat delay interval