What might be the most elegant way to throttle the a
,s
functions triggered by an EventHandler
such that the InputField
doesn't get to far behind in the following example? Just to clarify. I am looking to have the queued functions stop executing after either the a
or s
keys are released.
Here is an illustration of a similar issue to the one I am experiencing while in the Graphics3D
element.
i = 0;
a[] := (Pause[RandomInteger[{1, 9}]*.1]; i++;);
s[] := (Pause[RandomInteger[{1, 9}]*.1]; i--;);
EventHandler[InputField[Dynamic@i, Number], {"KeyDown" :> (
If[CurrentValue["EventKey"] == "a",
a[], s[]
]
)}
]
EDIT: If you hold down the a key I would like the unrun functions to either not run or somehow throttle the number of times the function is executed such that you can successfully hold down the a key for 2 seconds and then immediately(or as quickly as possible) hold down s key to subtract without a delay in the response. Ideally I would like to use the EventHandler
KeyReleased
option but I am currently unable to get such key to work.
a
key I would like the unrun functions to either not run or somehow throttle the number of times the function is executed such that you can successfully hold down thea
key for 2 seconds and then immediately(or as quickly as possible) hold downs
key to subtract without a delay in the response. $\endgroup$KeyReleased
would make this process a lot easier although I have been unable to get suchEventHandler
to work currently $\endgroup$